|  | 
|  | 
| вернуться в форум | Short solution Послано fjxttq  30 окт 2014 16:03Hi, 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 #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
 | 
 | 
|