Hammer and scissors cloth (20)

Source: Internet
Author: User

Time limit MS Memory limit 32768 KB code length limit (from small) to judging program standard 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

C C

B C

C C

C B

J B

B C

J J

Output Example:
5 3 2

2 3 5

C C

1#include <iostream>2 using namespacestd;3 intMain () {4     intn=Ten;5     CharJia;6     CharYi;7     intjias=0;8     intjiap=0;9     intI=0;Ten     intJiac=0;intjiaj=0;intjiab=0; One     intYic=0;intyij=0;intyib=0; A     Charjiaying='J'; -     Charyiying='J'; -Cin>>N; the      for(i=0; i<n;i++){ -Cin>>jia>>Yi; -         if(jia=='C'){ -             if(yi=='C'){ +jiap++; -}Else if(yi=='J'){ +jias++; AJiac++; at}Else{ -yib++; -             } -}Else if(jia=='J'){ -            if(yi=='J'){ -jiap++; in}Else if(yi=='B'){ -jias++; tojiaj++; +}Else{ -Yic++; the             } *}Else if(jia=='B'){ $             if(yi=='C'){Panax Notoginsengjias++; -jiab++; the}Else if(yi=='B'){ +jiap++; A}Else{ theyij++; +             } -         } $     } $cout<<jias<<" "<<jiap<<" "<<n-jias-jiap<<"\ n" -<<n-jias-jiap<<" "<<jiap<<" "<<Jias; -      the     if(jiaj<=jiac) -jiaying='C';Wuyi     if(jiac<=Jiab) thejiaying='B'; -cout<<"\ n"<<jiaying<<" "; Wu      -     if(yij<=yic) Aboutyiying='C'; $     if(yic<=Yib) -yiying='B'; -cout<<yiying<<Endl; -      A     return 0; +}

Hammer and scissors cloth (20)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.