Pat B 1018. Hammer and scissors cloth (20)

Source: Internet
Author: User

1018. Hammer and Scissors cloth (20) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Yue

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"stdio.h"2#include"string.h"3#include <stdlib.h>4 intMain ()5 {6     inti,b,ap=0, awin_c=0, awin_b=0, awin_j=0, alose_b=0, alose_c=0, alose_j=0;7     Charstr0,str2;8scanf"%d",&b);9      for(i=0; i<b;i++){TenGetChar ();//Enter Onescanf"%c%c",&str0,&str2); A         if(str0=='C') -         { -             if(str2=='C') theap++;//Draw -             if(str2=='J') -awin_c++;//a C win -             if(str2=='B') +alose_b++;//B wins -         } +         if(str0=='B') A         { at             if(str2=='B') -ap++; -             if(str2=='C') -awin_b++; -             if(str2=='J') -alose_j++; in         } -         if(str0=='J') to         { +             if(str2=='J') -ap++; the             if(str2=='B') *awin_j++; $             if(str2=='C')Panax NotoginsengAlose_c++; -         } the  +     } A  theprintf"%d%d%d\n", awin_b+awin_c+awin_j,ap,alose_c+alose_b+alose_j); +printf"%d%d%d\n", alose_c+alose_b+alose_j,ap,awin_b+awin_c+Awin_j); -      $  $      if(Awin_b>=awin_c&&awin_b>=awin_j) printf ("B"); -      if(Awin_c>awin_b&&awin_c>=awin_j) printf ("C"); -      if(Awin_j>awin_c&&awin_j>awin_b) printf ("J"); the  -      if(alose_b>=alose_c&&alose_b>=alose_j) printf ("B");Wuyi      if(alose_c>alose_b&&alose_c>=alose_j) printf ("C"); the      if(alose_j>alose_c&&alose_j>alose_b) printf ("J"); -  Wu     return 0; -}



Pat B 1018. Hammer and scissors cloth (20)

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.