1018. Hammer and Scissors cloth (20) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Yue
Everyone should play "Hammer and Scissors Cloth" game: two people at the same time give gestures, the rule of victory:
Now give a record of the confrontation between two people, please count the wins, flat, negative number of both sides, and give the two sides what gesture of the greatest odds.
Input format:
Enter line 1th to give the positive integer n (<=105), that is, the number of times the two sides clash. Then n lines, each row gives the information of a confrontation, that is, a, b both sides of the gesture given at the same time. C for "Hammer", J for "Scissors", B for "cloth", 1th letter for party A, 2nd for party B, 1 spaces in the middle.
Output format:
Output 1th, 2 respectively give a, B wins, flat, negative times, the number between 1 spaces separated. The 3rd line gives two letters, representing the most winning gestures of A and b, with 1 spaces in the middle. If the solution is not unique, the solution with the smallest alphabetic order is output.
Input Sample:
10C JJ BC bb bb cc cc BJ BB CJ J
Sample output:
5 3 3 5B B
1#include <stdio.h>2#include <math.h>3#include <stdlib.h>4#include <string.h>5 intMain ()6 {7 intN, x =0, y =0, C1 =0, C2 =0, J1 =0, J2 =0, B1 =0, b2 =0;8 CharA, B;9scanf"%d", &n);Ten GetChar (); One inti; A for(i =0; I < n; i++) - { -scanf"%c%c", &a, &b); the GetChar (); - if(A = ='C'&& b = ='J') - { -X + +; +c1++; - } + Else if(A = ='C'&& b = ='B') A { aty++; -b2++; - } - Else if(A = ='J'&& b = ='C') - { -y++; inc2++; - } to Else if(A = ='J'&& b = ='B') + { -X + +; thej1++; * } $ Else if(A = ='B'&& b = ='C')Panax Notoginseng { -X + +; theb1++; + } A Else if(A = ='B'&& b = ='J') the { +y++; -j2++; $ } $ } -printf"%d%d%d\n", X, N-x-y, y); -printf"%d%d%d\n", Y, N-x-y, x); the if(B1 >= C1 && B1 >=J1) -printf"B");Wuyi Else if(C1 > B1 && C1 >=J1) theprintf"C"); - Else if(J1 > B1 && j1 >C1) Wuprintf"J"); - if(B2 >= C2 && B2 >=J2) Aboutprintf"b\n"); $ Else if(C2 > B2 && c2 >=J2) -printf"c\n"); - Else if(J2 > B2 && j2 >C2) -printf"j\n"); A return 0; +}
1018. Hammer and scissors cloth