题目链接
代码如下
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,a[3]={0},b[3]={0},a1[3]={0},b1[3]={0};
char ss1,ss2;
scanf("%d",&n);
while(n--){getchar();
scanf("%c %c",&ss1,&ss2);
switch(ss1){case 'C':{switch(ss2){
case 'C':{a[1]++;b[1]++;break;}
case 'J':{a[0]++;b[2]++;a1[0]++;break;}
case 'B':{a[2]++;b[0]++;b1[2]++;break;}
}break;
}
case 'J':{switch(ss2){
case 'J':{a[1]++;b[1]++;break;}
case 'B':{a[0]++;b[2]++;a1[1]++;break;}
case 'C':{a[2]++;b[0]++;b1[0]++;break;}
}break;
}
case 'B':{switch(ss2){
case 'B':{a[1]++;b[1]++;break;}
case 'C':{a[0]++;b[2]++;a1[2]++;break;}
case 'J':{a[2]++;b[0]++;b1[1]++;break;}
}break;
}}}
for(int i=0;i<3;i++){
printf("%d",a[i]);if(i!=2)printf(" ");
}
cout<<endl;
for(int i=0;i<3;i++){
printf("%d",b[i]);if(i!=2)printf(" ");
}
cout<<endl;
if(a1[2]>=a1[0]){
if(a1[2]>=a1[1])printf("B " );
else printf("J ");
}
else{
if(a1[0]>=a1[1])printf("C ");
else printf("J ");
}
if(b1[2]>=b1[0]){
if(b1[2]>=b1[1])printf("B" );
else printf("J");
}
else{
if(b1[0]>=b1[1])printf("C");
else printf("J");
}
return 0;
}