http://acm.tju.edu.cn/toj/showp1721.html
//640827 2009-05-18 17:58:06 Accepted 1721 C++ 1.6K 0'00.00" 1212K asliyunsong #include<iostream> #include<string> #include<map> using namespace std;
int main() { int tc,T; int j,len; string str,names; string pep[] = {"a","Anne","Bob","Karin","Charly","Dave","Edward","Frank"}; scanf("%d",&T); getchar(); for(tc = 1; tc <= T;tc ++) { map<string,int> M; getline(cin,str); str += " "; len = str.length(); names = ""; for(j = 0;j<len;j++) { if(str[j] == ' ') { M[names] = 1; names = ""; } else names += str[j]; } int pt1 ,pt2,pt3; pt1 = pt2 = pt3 = 0; if(M[pep[1]] == 1) pt1++; if(M[pep[2]] == 1) { if(M[pep[3]] == 1 && M[pep[5]] == 0 && M[pep[1]] == 1 && M[pep[6]] == 0) pt2++; else if(M[pep[3]] == 0 && ( M[pep[5]] == 1 || M[pep[1]] == 0 || M[pep[6]] == 1)) pt3 ++; } if(M[pep[3]] == 1) { if(M[pep[4]] == 1 ) pt2++; else if(M[pep[4]] == 0 && M[pep[1]] == 1 ) pt1 ++; else if(M[pep[4]] == 0 && M[pep[1]] == 0 ) pt3 ++; } if(M[pep[4]] == 1) { if(M[pep[1]] == 1 ) pt1++; }
if(M[pep[6]] == 1) { if(M[pep[4]] == 0 && M[pep[1]] == 1 ) pt3++; else pt1 ++; }
if(M[pep[7]] == 1) { if(M[pep[2]] == 0 && M[pep[1]] == 0 ) pt1 ++; else if(M[pep[1]] == 1 ) pt2 ++; } printf("Scenario #%d:\n",tc);
if(pt1 > pt2 && pt1 > pt3) { cout<<"cinema"<<endl; } else if(pt2 > pt1 && pt2 > pt3) { cout<<"disco"<<endl; } else if(pt3 > pt2 && pt3 > pt1) { cout<<"cocktail bar"<<endl; } else cout<<"stay at the Hacienda"<<endl;
cout<<endl; } return 0; }
|