Codeforces Round #281 (Div. 2) A. Vasya and Football violence

Source: Internet
Author: User

A. Vasya and Football

Vasya had started watching football games. He has learned this for some fouls the players receive yellow cards, and for some fouls, they receive red cards. A player who receives the second yellow card automatically receives a red card.

Vasya is watching a recorded football match now and makes notes of all the fouls so he would give a card for. Help Vasya determine all the moments in time when players would be given red cards if Vasya were the judge. For each player, Vasya wants to know only the first moment of time andhe would receive a red card from Vasya.

Input

The first line contains the name of the team playing at home. The second line contains the name of the team playing away. Both lines is not empty. The lengths of both lines does not exceed 20. Each line contains only of large 中文版 letters. The names of the teams is distinct.

Next follows number n (1≤ n ≤90)-the number of fouls.

Each of the following n lines contains information on a foul in the following form:

    • first goes number  t   (1≤ T ≤90)- The minute when the foul occurs;
    • then goes letter "h" or "a"-if "h", then the card is given to a home team player, otherwise the card is given to an AW Ay team player;
    •  
    • then goes the player ' s Number  m   (1≤ m ≤99);
    • then goes letter "y" or "r"-if "y", that means the yellow card is given, otherwise the red card was given.

The players from different teams can has the the same number. The players within one team has distinct numbers. The fouls go chronologically, no. Fouls happened at the same minute.

Output

For each event if a player received his first red card in a chronological order print a string containing the follow ing information:

    • The name of the team to which the player belongs;
    • The player's number in his team;
    • The minute when he received the card.

If no player received a card, then you does not need to print anything.

It's possible case, the program won't print anything to the output (if there were no red cards).

Sample Test (s)input
Mc
CSKA
9
3 A Y
H-Y
The H-Y
H y
A 4 y
A-y
+-H
H + Y
A-R
Output
MC 25 70
MC 42 82
CSKA 13 90

Test Instructions : Two football teams give you n red cards, two yellow cards = a red card = Sent off the game. Asking you to be sent off as time increases.

The following:

Do not repeat the output sent off the same person the situation is that the violence

///Meek#include <bits/stdc++.h>using namespaceStd;typedefLong Longll;#defineMem (a) memset (A,0,sizeof (a))#definePB Push_backinline ll read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){        if(ch=='-') f=-1; ch=GetChar (); }     while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar (); }returnx*F;}//****************************************Const intn=8005;#defineMoD 10000007#defineINF 10000007#defineMAXN 10000Charh[ -],a[ -],ch[ A],ch2[ A];map<string,string>Mp;map<string,int>MPs;inthh[ +];intah[ +];intu[ -];intMain () {mem (HH), mem (AH); Mp.clear (); scanf ("%s%s", H,a); intn=read (), T,num;  for(intI=1; i<=n;i++) {scanf ("%d%s%d%s",&t,ch,&NUM,CH2); if(ch2[0]=='y') {             if(ch[0]=='a') {Ah[num]++; if(ah[num]>2)Continue; if(ah[num]==2) {cout<<a<<" "<<num<<" "<<t<<Endl; }             }             Else{Hh[num]++; if(hh[num]>2)Continue; if(hh[num]==2) {cout<" "<<num<<" "<<t<<Endl; }             }        }        Else {            if(ch[0]=='a') {                if(ah[num]>=2)Continue; Ah[num]+=2; cout<<a<<" "<<num<<" "<<t<<Endl; }            Else {                if(hh[num]>=2)Continue; Hh[num]+=2; cout<" "<<num<<" "<<t<<Endl; }        }    }    return 0;}
Code

Codeforces Round #281 (Div. 2) A. Vasya and Football violence

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.