# 1018. 锤子剪刀布 (20)

100 ms

65536 kB

8000 B

Standard

CHEN, Yue

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 <iostream>
using namespace std;
#define C 0
#define J 1
#define B 2

int wintimea[3] = { 0 };
int wintimeb[3] = { 0 };

int judge(char a, char b)//判决函数
{
int judge;
if (a == 'C' && b == 'B') {
judge = -1;//b用B赢了
wintimeb[B]++;
}
else if (a == 'B' && b == 'J') {
judge = -1;//b用J赢了
wintimeb[J]++;
}
else if (a == 'J' && b == 'C') {
judge = -1;//b用C赢了
wintimeb[C]++;
}
else if (a == 'B' && b == 'C') {
judge = 1;//a用B赢了
wintimea[B]++;
}
else if (a == 'J' && b == 'B') {
judge = 1;//a用J赢了
wintimea[J]++;
}
else if (a == 'C' && b == 'J') {
judge = 1;//a用C赢了
wintimea[C]++;
}
else if (a == b) {
judge = 0;
}
return judge;
}

int main()
{
int n;
int result;
cin >> n;
char a, b;
int wina = 0, winb = 0, draw = 0;

for (int i = 0; i < n; i++) {
cin >> a >> b;

result = judge(a, b);
if (result == 0)
draw++;
else if (result < 0)
winb++;
else
wina++;
}

cout << wina << " " << draw << " " << winb << endl;
cout << winb << " " << draw << " " << wina << endl;

char MaxA = ((wintimea[C]>wintimea[B]&&wintimea[C]>=wintimea[J])?'C':(wintimea[B]>=wintimea[J]?'B':'J'));
char MaxB = ((wintimeb[C]>wintimeb[B]&&wintimeb[C]>=wintimeb[J])?'C':(wintimeb[B]>=wintimeb[J]?'B':'J'));
cout << MaxA << " " << MaxB;

return 0;
}