题目描述
大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:
现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。
输入
输入第1行给出正整数N(<=105),即双方交锋的次数。随后N行,每行给出一次交锋的信息,即甲、乙双方同时给出的的手势。C代表“锤子”、J代表“剪刀”、B代表“布”,第1个字母代表甲方,第2个代表乙方,中间有1个空格。
输出
输出第1、2行分别给出甲、乙的胜、平、负次数,数字间以1个空格分隔。第3行给出两个字母,分别代表甲、乙获胜次数最多的手势,中间有1个空格。如果解不唯一,则输出按字母序最小的解。
样例输入
10
C J
J B
C B
B B
B C
C C
C B
J B
B C
J J
样例输出
5 3 2
2 3 5
B B
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
char _get(int c,int j,int b){
int max=c;
char temp='C';
if(c<j){
max=j;
temp='J';
if(max<=b)
temp='B';
//return temp;
}else if(c<=b){
max=b;
temp='B';
}
return temp;
}
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int n=0;
cin>>n;
int t1=0,t2=0,t3=0,t4=0,t5=0,t6=0,t7=0,t8=0,t9=0;
for(int i=0;i<=n;i++){
char a=' ',b=' ';
//scanf("%c %c",&a,&b);
cin>>a>>b;
if(a=='C'){
if(b=='C'){
t1++;//ping
}else if(b=='J'){
t2++;//sheng
t4++;
}else if(b=='B'){
t3++;//shu
t7++;
}
}
else if(a=='J'){
if(b=='C'){
t3++;//shu
t8++;
}else if(b=='J'){
t1++;//ping
}else if(b=='B'){
t2++;//sheng
t5++;
}
}
else if(a=='B'){
if(b=='C'){
t2++;//sheng
t6++;
}else if(b=='J'){
t3++;//shu
t9++;
}else if(b=='B'){
t1++;//ping
}
}
}
cout<<t2<<' '<<t1<<' '<<t3<<endl;
cout<<t3<<' '<<t1<<' '<<t2<<endl;
char temp,temp1;
temp=_get(t4,t5,t6);
temp1=_get(t8,t9,t7);//order by c,j,b
cout<<temp<<' '<<temp1<<endl;
cin.get();
return 0;
}