1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include<cstdio> #include<map> using namespace std; int judge(char a,char b){ if(a=='J'&&b=='B'){ return 2; } else if(a=='B'&&b=='C'){ return 2; } else if(a=='C'&&b=='J'){ return 2; } else if(a=='B'&&b=='J'){ return 1; } else if(a=='C'&&b=='B'){ return 1; } else if(a=='J'&&b=='C'){ return 1; }else{ return 0; }
} map<char,int> anum,bnum; int main(){ int n; scanf("%d",&n); char a,b; int acnt,bcnt,cnt; acnt=bcnt=cnt=0; while(n--){ scanf("\n%c %c",&a,&b); if(judge(a,b)==2){ acnt++; anum[a]++; }else if(judge(a,b)==1){ bcnt++; bnum[b]++; }else{ cnt++; } } printf("%d %d %d\n%d %d %d\n", acnt,cnt,bcnt,bcnt,cnt,acnt); acnt=bcnt=-1; for (map<char,int>::iterator it=anum.begin();it!=anum.end(); ++it) { if (it->second>acnt) { a=it->first; acnt=it->second; } } for (map<char,int>::iterator it=bnum.begin();it!=bnum.end(); ++it) { if (it->second>bcnt) { b=it->first; bcnt=it->second; } } printf("%c %c\n", a,b); return 0; }
|