Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
疯掉……一个小时,那里有错啊?郁闷!#include<iostream> #include<map> #include<cstring> #include<algorithm> #include<cstdio> using namespace std; int main() { map<string,string>party; map<string,int>vote; string str1,str2; int m; int n; cin>>n; //getline(cin,str1); getchar(); for(int i=0;i<n;i++) { getline(cin,str1); getline(cin,str2); party[str1]=str2; vote[str1]=2; } cin>>m; getchar(); // getline(cin,str1); for(int i=0;i<m;i++) { getline(cin,str1); if(vote[str1]>=2) vote[str1]++; } int max=0; int MK=0; map<string,int>::iterator it; for(it=vote.begin();it!=vote.end();it++) { if(it->second>max){ str2=it->first; if(MK==1)MK=0; } if(it->second==max)MK=1; } if(MK==1)cout<<"tie"<<endl; else cout<<party[str2]<<endl; //system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator