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 the 1th line to give the positive integer n (<=105), which 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
Import Java.util.arrays;import java.util.scanner;/** * @author jwang1 Success factors */public class Main {public static void Main (string[] args) {Scanner cin = new Scanner (system.in); Char A, B; int icountwin = 0; int icounteven = 0; int[] Cnt1 = new int[] {0, 0, 0}; int[] Cnt2 = new int[] {0, 0, 0}; int n = cin.nextint (); for (int i = 0; i < n; i++) {a = Cin.next (). charAt (0); b = Cin.next (). charAt (0); int ret = Comp (A, b); if (1 = = ret) {icountwin++; Cnt1[mapping (a)]++; } else if (0 = = ret) {icounteven++; } else {cnt2[mapping (b)]++; }} System.out.println (Icountwin + "" + Icounteven + "" + (N-icounteven-icountwin) + "\ n" + (N-icount Even-icountwin) + "+ Icounteven +" "+ Icountwin +" \ n "+ Maxchar (cnt1) +" "+ Maxchar (Cnt2)); } public static char Maxchar (int[] charray) {int max = Integer.min_value; for (int i = 0; i < charray.length; i++) {if (Charray[i] > max) {max = charray[i]; }} if (charray[0] = = max) return ' B '; if (charray[1] = = max) return ' C '; Return ' J '; } public static int comp (char A, char b) {if (a = = B) return 0; if (' C ' = = a && ' J ' = = b) | | (' J ' = = a && ' b ' = = b) | | (' b ' = = a && ' C ' = = b)) return 1; return-1; } public static int mapping (char c) {int result =-1; Switch (c) {case ' B ': result = 0; Break Case ' C ': result = 1; Break Case ' J ': result = 2; Break } return result; }}