1022: Hammer and scissors time limit: 1 Sec memory limit: MB
Submitted by: 245 Resolution: 211
Submitted State [Discussion Version] 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
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
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.
Sample input
10C JJ BC bb bb cc cc BJ BB CJ J
Sample output
5 3 3 5B B
Hint Source
5053
#include <iostream>
using namespace Std;
int compare (char A,char b) {
if (a==b) return 0;
if (a== ' C ') {
if (b== ' B ') return-1;
else if (b== ' J ') return 1;
}else if (a== ' B ') {
if (b== ' J ') return-1;
else if (b== ' C ') return 1;
}else if (a== ' J ') {
if (b== ' C ') return-1;
else if (b== ' B ') return 1;
}
}
int main () {
int n,i,sheng,ping,fu;
int c1,b1,j1,c2,b2,j2,max1,max2;
Char a,b,s1,s2;
sheng=0;
ping=0;
fu=0;
c1=0;
b1=0;
j1=0;
c2=0;
b2=0;
j2=0;
cin>>n;
for (i=0;i<n;i++) {
cin>>a>>b;
if (compare (A, b) ==1) {
sheng++;
if (a== ' C ') c1++;
else if (a== ' B ') b1++;
else if (a== ' J ') j1++;
}else if (compare (A, b) ==-1) {
fu++;
if (b== ' C ') c2++;
else if (b== ' B ') b2++;
else if (b== ' J ') j2++;
}else if (compare (A, b) ==0) {
ping++;
}
}
max1= (B1>=C1)? (b1>=j1?b1:j1):(c1>=j1?c1:j1);
Max2= (B2>=C2)? (B2>=J2?B2:J2):(c2>=j2?c2:j2);
s1= (MAX1==B1)? ' B ':(max1==c1? ' C ': ' J ');
S2= (max2==b2)? ' B ':(max2==c2? ' C ': ' J ');
cout<<sheng<< "" <<ping<< "" <<fu<<endl;
cout<<fu<< "" <<ping<< "" <<sheng<<endl;
cout<<s1<< "" <<s2<<endl;
return 0;
}
1022: Hammer and scissors cloth