1018. Hammer and Scissors Cloth (20) (Math ah Zju_pat)

Source: Internet
Author: User

Title Link: http://www.patest.cn/contests/pat-b-practise/1018


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 the 1th line to give the positive integer n (<=105), which 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

The code is as follows:

#include <cstdio>int main () {int n;    int a1=0,a2=0,a3=0;//A win, draw, B win int aj=0,ac=0,ab=0;//out what way to win multiple int bj=0,bc=0,bb=0;    Char x,y,blank;scanf ("%d", &n);        for (int i = 0; i < n; i++) {GetChar ();        scanf ("%c%*c%c", &x,&y);        if ((x== ' C ') && (y== ' J ')) {a1++; ac++; continue;}        if (x== ' J ') && (y== ' B ')) {a1++; aj++; continue;}        if ((x== ' B ') && (y== ' C ')) {a1++; ab++; continue;}        if ((x== ' C ') && (y== ' C ')) {a2++; continue;}        if (x== ' J ') && (y== ' J ')) {a2++; continue;}        if ((x== ' B ') && (y== ' B ')) {a2++; continue;}        if ((x== ' C ') && (y== ' B ')) {a3++; bb++; continue;}        if (x== ' B ') && (y== ' J ')) {a3++; bj++; continue;}    if (x== ' J ') && (y== ' C ')) {a3++; bc++; continue;}    }printf ("%d%d%d\n", a1,a2,a3);p rintf ("%d%d%d\n", A3,A2,A1);    if ((AB&GT;=AC) && (Ab>=aj)) printf ("B");    else if (AC >= AJ) printf ("C");    else printf ("J"); if ((bb>=BC) && (BB&GT;=BJ)) printf ("b\n");    else if (BC&GT;=BJ) printf ("c\n");    else printf ("j\n"); return 0;}


1018. Hammer and Scissors Cloth (20) (Math ah Zju_pat)

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.