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
Run timeout, but the result is correct, and the compiler is very old, do not support switch (string) type, so changed to the following way, another time to write the C + + version of the
Import Java.util.scanner;enum Tempchar {B, C, J; public static Tempchar GetChar (String s) {return valueOf (s); }} public class main {public static void main (string[] args) {Scanner scan = new Scanner (system.in); int num =scan.nexti NT (); int i=0;int a[]={0,0,0};//record a wins, flat, negative//int b[]={0,0,0};//record B wins, flat, negative int c[]={0,0,0};//record a The most winning gestures, respectively B,c,jint d[]={ 0,0,0};while (i<num) {String temp = Scan.next (); String temp2= scan.next (); switch (Tempchar.getchar (temp)) {Case B:switch (Tempchar.getchar (TEMP2)) {case b:a[1]++; Break;case c:a[0]++;c[0]++;break;case j:a[2]++;d [2]++;break;} Break;case C:switch (Tempchar.getchar (TEMP2)) {case b:a[2]++;d [0]++;break;case c:a[1]++;break;case J:a[0]++;c[1]++; break;} Break;case J:switch (Tempchar.getchar (TEMP2)) {case B:a[0]++;c[2]++;break;case c:a[2]++;d [1]++;break;case J:a[1]++; break;} break;} i++;} int Max1=0,max2=0;for (i=1;i<3;i++) {if (C[i]>c[max1]) {max1 = i;} if (D[i]>d[max2]) {max2 = i;}} System.out.println (a[0]+ "" +a[1]+ "" +a[2] "); SysteM.out.println (a[2]+ "" +a[1]+ "" +a[0] "), switch (MAX1) {case 0:system.out.print (" B "+" "); Break;case 1:system.out.print (" C "+" "); Break;case 2:system.out.print (" J "+"); break;} Switch (MAX2) {case 0:system.out.print ("B"), Break;case 1:system.out.print ("C"); Break;case 2:system.out.print ("J"); Break;}}}
1018. Hammer and Scissors cloth (20)