Title Description
Everyone should play "a hammer and scissors" game: they both give gesture, as shown in the outcome of the rules
Now given the two men clash records, statistics of both wins, flat, negative number, and gives both parties are at the greatest chance of winning what gesture
Input Format
The first line gives a positive integer N (≤ 10 . 5 ), i.e., both the number of confrontation. Then N rows, each row gives information confrontation, i.e., the gesture and B sides given simultaneously. C stands for "hammer", the representative J "see", B stands for "cloth", the first letter represents a party, on behalf of the second letter B, the middle of a space
Output Format
First, two lines are given A, B wins, flat, negative times, with a space between digits. The third line is given two letters represent A, B wins the highest number of gestures, a space intermediate
If the solution is not unique, the minimum output lexicographical ordering Solutions
SAMPLE INPUT
10
CJ
JB
CB
BB
BC
CC
CB
JB
BC
JJ
Sample Output
5 3 2
2 3 5
B B
#include <bits/stdc++.h> int change(char c){ if(c == 'B'){ return 0; } if(c == 'C'){ return 1; } if(c == 'J'){ return 2; } } char unchange(int n){ if(n == 0){ return 'B'; } if(n == 1){ return 'C'; } if(n == 2){ return 'J'; } } int main(int argc, char *argv[]) { int n; Scanf ( " % D " , & n-); // Number of rows int times_A [ . 3 ] = { 0 , 0 , 0 }, times_B [ . 3 ] = { 0 , 0 , 0 }; // record the number of times even negative AB char C1, C2; int K1, K2; int count1 is [ . 3 ] = { 0 , 0 , 0 }, count2 [ . 3 ] = { 0 , 0 , 0 }; // record A, b number of wins int MAX1, MAX2, index1,, index2; // record corresponding to the maximum and the maximum array index for ( int I = 0 ; I <n-; I ++ ) { getchar(); Scanf ( " % C% C " , & C1, & C2); // gesture into digital K1 = Change (C1); K2 = Change (C2); // A win IF ((K1 + . 1 )% . 3 == K2) { times_A[0]++; times_B[2]++; count1[k1]++; // 平手 }else if(k1 == k2){ times_A[1]++; times_B[1]++; // 乙赢 }else if((k2 + 1)%3 == k1){ times_A[2]++; times_B[0]++; count2[k2]++; } } printf("%d %d %d\n", times_A[0], times_A[1], times_A[2]); printf("%d %d %d\n", times_B[0], times_B[1], times_B[2]); max1 = count1[0]; max2 = count2[0]; index1 = 0; index2 = 0; for(int i = 1;i < 3; i++){ if(max1 < count1[i]){ max1 = count1[i]; index1 = i; } if(max2 < count2[i]){ max2 = count2[i]; index2 = i; } } printf("%c %c", unchange(index1), unchange(index2)); return 0; }
The key problem solution
- Shengping Fu calculated when the gesture indicating letters in lexicographic order conversion digital computing, B, C, J, are converted to 0,1,2,0 wins wins 2,2 1,1 0 wins, the cycle is determined