ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1496. Spammer

Short solution
Posted by fjxttq 30 Oct 2014 16:03
Hi, here's a very short and clear solution I came up with in a few seconds.
I guess somebody'll like the trick used in it.

#include <bits/stdc++.h>
using namespace std;
int n,i;
string s;
map<string,int>M;
int main(){
    //freopen("input.txt","r",stdin);
    cin>>n;
    for(i=1;i<=n;++i){
        cin>>s;
        ++M[s];
        if(M[s]>1)cout<<s<<endl,M[s]=-1e9;
    }
    return 0;
}
Re: Short solution
Posted by falicos 12 Sep 2016 09:55
#include <bits/stdc++.h>
using namespace std;
string s;
map<string,int>M;
int main(){
        while (getline(cin, s)){
        ++M[s];
        if(M[s]>1)cout<<s<<endl,M[s]=-1e9;
    }
    return 0;
}
This is shorter .... Get Ac, but wrong . Weak tests.

Edited by author 12.09.2016 09:59