1018. Hammer and Scissors cloth (20)
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 <iostream>2 using namespacestd;3 intMain () {4 Charc1,c2;5 Charch[6]={'B','C','J','J','B','C'};6 inttag[9]={0};//0: Win, 1 Ping, 2 lose, 3:b win, 4:c win, 5:j win, 6:b lose, 7:c lose, 8:j lose7 intN Cin>>N;8 while(n--){9Cin>>c1>>C2;Ten if(c1=='C'&&c2=='C') {tag[1]++;} One if(c1=='C'&&c2=='J') {tag[0]++; tag[4]++;} A if(c1=='C'&&c2=='B') {tag[2]++; tag[7]++;} - if(c1=='J'&&c2=='J') {tag[1]++;} - if(c1=='J'&&c2=='B') {tag[0]++; tag[5]++;} the if(c1=='J'&&c2=='C') {tag[2]++; tag[8]++;} - if(c1=='B'&&c2=='B') {tag[1]++;} - if(c1=='B'&&c2=='C') {tag[0]++; tag[3]++;} - if(c1=='B'&&c2=='J') {tag[2]++; tag[6]++;} + } - intM,n,max; +max=0; A for(intI=3; i<=5; i++) at if(Tag[i]>max) {Max=tag[i]; c1=ch[i-3];} -max=0; - for(intI=6; i<=8; i++) - if(Tag[i]>max) {Max=tag[i]; c2=ch[i-3];} -cout<<tag[0]<<" "<<tag[1]<<" "<<tag[2]<<Endl; -cout<<tag[2]<<" "<<tag[1]<<" "<<tag[0]<<Endl; incout<<c1<<" "<<C2; - return 0; to}View Code
PAT 1018. Hammer and scissors cloth