文章目录
题目
输入样例:
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<stdio.h>
#include <iostream>
#include<algorithm>
#include <string.h>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int js[3] = { 0 }, ys[3] = { 0 };
int pan(char x, char y){
if (x == y)return 0;
if ((x == 'C'&&y == 'J') || (x == 'J'&&y == 'B') || (x == 'B'&&y == 'C')){
if (x == 'C')js[0]++;
else if (x == 'J')js[1]++;
else js[2]++;
return 1;
}
else{
if (y == 'C')ys[0]++;
else if (y == 'J')ys[1]++;
else ys[2]++;
return -1;
}
}
int main(){
int n;
cin >> n;
char jia[100001], yi[100001];
int jias = 0, jiap = 0, jiaf = 0;
for (int i = 0; i < n; i++){
cin >> jia[i] >> yi[i];
}
for (int i = 0; i < n; i++){
int x = pan(jia[i], yi[i]);
if (x > 0)jias++;
else if (x == 0)jiap++;
else
jiaf++;
}
cout << jias << " " << jiap << " " << jiaf << endl;
cout << jiaf << " " << jiap << " " << jias << endl;
int jmax = max(js[0], max(js[1], js[2])), ymax = max(ys[0], max(ys[1], ys[2]));
//cout << endl << jmax << " " << ymax << endl;
if (js[2] == jmax)cout << "B ";
else if (js[0] == jmax)cout << "C ";
else cout << "J ";
if (ys[2] == ymax)cout << "B";
else if (ys[0] == ymax)cout << "C";
else cout << "J";
system("pause");
return 0;
}