
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
char a,b;
int p=0,y=0,s=0;
int Pb=0,Pc=0,Pj=0;
int b1=0,c1=0,j1=0;
while(n--)
{
cin>>a>>b;
if(a=='B'&&b=='B')
p++;
else if(a=='B'&&b=='C')
{
y++;
Pb++;
}
else if(a=='B'&&b=='J')
{
s++;
j1++;
}
else if(a=='C'&&b=='C')
p++;
else if(a=='C'&&b=='B')
{
s++;
b1++;
}
else if(a=='C'&&b=='J')
{
y++;
Pc++;
}
else if(a=='J'&&b=='J')
p++;
else if(a=='J'&&b=='B')
{
y++;
Pj++;
}
else if(a=='J'&&b=='C')
{
s++;
c1++;
}
}
//cout<<Pb<<" "<<Pc<<" "<<Pj<<endl;
//cout<<b1<<" "<<c1<<" "<<j1<<endl;
cout<<y<<" "<<p<<" "<<s<<endl;
cout<<s<<" "<<p<<" "<<y<<endl;
if(Pb>Pc&&Pb>Pj)
cout<<"B ";
else if(Pc>Pb&&Pc>Pj)
cout<<"C ";
else if(Pj>Pc&&Pj>Pb)
cout<<"J ";
else if(Pb==Pc&&Pj<Pb)
cout<<"C ";
else if(Pb==Pj&&Pc<Pb)
cout<<"B ";
else if(Pj==Pc&&Pj>Pb)
cout<<"C ";
else
{
cout<<"B ";
}
if(b1>c1&&b1>j1)
cout<<"B"<<endl;
else if(c1>b1&&c1>j1)
cout<<"C"<<endl;
else if(j1>c1&&j1>b1)
cout<<"J"<<endl;
else if(b1==c1&&j1<b1)
cout<<"C ";
else if(b1==j1&&c1<b1)
cout<<"B ";
else if(j1==c1&&j1>b1)
cout<<"C ";
else
{
cout<<"B"<<endl;
}
return 0;
}
这题思路很简单,就是过程麻烦了,最后的18分,发现解
不唯一,则输出按字母序最小的解。这个没有判断