Hammer and scissors cloth
Title Description
Everyone should play "Hammer and Scissors cloth" game:
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 Description:
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 Stands for "Hammer", J for "Scissors", and b generation
Table "Cloth", the 1th letter represents party A, the 2nd represents party B, there are 1 spaces in the middle.
Output Description:
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 the only
One, the output is sorted by the smallest alphabetic order.
Input Example:
10
C J
J B
C B
b b
B C
C C
C B
J B
B C
J J
Output Example:
5 3 2
2 3 5
b b
Python:
num =int (input ()) J=[0,0,0]y=[0,0,0]j2= {'B': 0.2,'C': 0.1,'J': 0} #添加小数是为了让其在相同数字时, sorted by alphabetical output Y2= {'B': 0.2,'C': 0.1,'J': 0} # forIinchrange (num): a=input (). Split ()ifA[0] = = a[1]: j[1] + = 1y[1] + = 1elif(a[0]=='C' anda[1]=='J')or(a[0]=='J' anda[1]=='B')or(a[0]=='B' anda[1]=='C'): j[0]+ = 1y[2] + = 1J2[a[0]]+ = 1Else: j[2] + = 1Y[0]+ = 1y2[a[1]] + = 1Print(j[0],j[1],j[2])Print(y[0],y[1],y[2])Print(List (J2.keys ()) [List (J2.values ()). Index (Max (J2.values ()))],list (Y2.keys ()) [List (Y2.values ()). Index (MAX ( Y2.values ()))])
B (Basic level) 1008 hammer and scissors cloth