who falls first

L1-019. Who falls first

time limit
400 ms
memory limit
65536 kB
code length limit
8000 B
Judgment procedure
Standard
author
Chen Yue

Boxing is an interesting part of ancient Chinese wine culture. The method for two people at the wine table is to call out a number in each mouth and draw a number with their hands at the same time. If whoever draws the number exactly equals the sum of the numbers shouted by the two, whoever loses, the loser will be fined a glass of wine. Two wins or two losses continue to the next round until the only winner emerges.

The following is the amount of alcohol A and B can drink (the maximum number of drinks they can drink without pouring) and the punching records. Please judge who pours first.

Input format:

Enter the first line of the input to give the amount of alcohol for A and B (a non-negative integer not exceeding 100), separated by spaces. The next line gives a positive integer N (<=100), followed by N lines, each line gives the record of a round of punches, the format is:

A shouts A, B shouts B

Among them, "Shout" is the number that is called out, and "Draw" is the number to be drawn, both of which are positive integers not exceeding 100 (draw with both hands).

Output format:

In the first line output the person who fell first: A for A and B for B. The second line prints how many glasses the person who didn't pour drank. The title guarantees that one person will fall. Note that the program will terminate when someone falls, and the subsequent data does not need to be processed.

Input sample:
1 1
6
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15
15 1 1 16
Sample output:
A
1
#include<iostream>
using namespace std;
int main(){
    int a,b,n,x1,y1,x2,y2;
    cin>>a>>b;
    cin>>n;
    for(int i=1,flag1=0,flag2=0;i<=n;i++){
        cin>>x1>>y1>>x2>>y2;
        if(((x1+x2)==y1)&&((x1+x2)!=y2))
            flag1 ++;
        if(((x1+x2)==y2)&&((x1+x2)!=y1))
          flag2++;
        if(flag1>a){
            cout<<"A"<<endl<<flag2<<endl;
            break;
        }
        if(flag2>b){
            cout<<"B"<<endl<<flag1<<endl;
            break;
        }
    }
return 0;
}

Note: In the event of a tie, the game will continue without penalty

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325670430&siteId=291194637