PAT 乙级 1018 锤子剪刀布
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
map<char, int> mp;
int timeA[N], timeB[N];
int cntA[N], cntB[N];
char s[3] = {'B', 'C', 'J'};
void init() {
mp['B'] = 0;
mp['C'] = 1;
mp['J'] = 2;
}
int main() {
init();
int n;
cin >> n;
char c1, c2;
while(n--) {
cin >> c1 >> c2;
if (mp[c2] == (mp[c1] + 1) % 3) {
timeA[0]++;
timeB[2]++;
cntA[mp[c1]]++;
} else if (mp[c1] == (mp[c2] + 1) % 3) {
timeB[0]++;
timeA[2]++;
cntB[mp[c2]]++;
} else {
timeA[1]++;
timeB[1]++;
}
}
int maxA = -1, maxB = -1;
int num1, num2;
for (int i = 0; i < 3; i++) {
if (cntA[i] > maxA) {
maxA = cntA[i];
num1 = i;
}
if (cntB[i] > maxB) {
maxB = cntB[i];
num2 = i;
}
}
for (int i = 0; i < 3; i++) {
cout << timeA[i];
if (i < 2) cout << " ";
}
cout << endl;
for (int i = 0; i < 3; i++) {
cout << timeB[i];
if (i < 2) cout << " ";
}
cout << endl;
cout << s[num1] << " " << s[num2];
return 0;
}