493A Vasya and Football


/*
A. Vasya and Football


time limit per test:2 seconds


memory limit per test:256 megabytes


input:standard input


output:standard output




Vasya has started watching football games. He has learned that 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 that 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 when he 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 are not empty. The lengths of both lines do not exceed 20. Each line contains only of large English letters. The names of the teams are distinct.


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


Each of the following n lines contains information about a foul in the following form:
• first goes number t (1 ≤ t ≤ 90) — the minute when the foul occurs;
• then goes letter "h" or letter "a" — if the letter is "h", then the card was given to a home team player, otherwise the card was given to an away team player;
• then goes the player's number m (1 ≤ m ≤ 99);
• then goes letter "y" or letter "r" — if the letter is "y", that means that the yellow card was given, otherwise the red card was given.


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




Output


For each event when a player received his first red card in a chronological order print a string containing the following 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 do not need to print anything.


It is possible case that the program will not print anything to the output (if there were no red cards).




Sample test(s)






Input
MC
CSKA
9
28 a 3 y
62 h 25 y
66 h 42 y
70 h 25 y
77 a 4 y
79 a 25 y
82 h 42 r
89 h 16 y
90 a 13 r






Output
MC 25 70
MC 42 82
CSKA 13 90
*/


#include<stdio.h>
int main()
{
    int hom[110]={0},ary[110]={0};
    int thom[110]={0},tary[110]={0};
    char sh[25],sa[25];
    char c;
    scanf("%s%s",sh,sa);
    int _,time,temp,flag=0;
    scanf("%d",&_);
    while(_--)
    {
        scanf("%d",&time);
        getchar();
        if((c=getchar())=='h') {
            scanf("%d",&temp);thom[temp]=time;
            if(getchar()&&(c=getchar())=='y') hom[temp]++;
            else hom[temp]+=2;
            if(hom[temp]==2||(hom[temp]==3&&c=='r')){printf("%s %d %d\n",sh,temp,time);flag=1;}
        }
        else{
            scanf("%d",&temp);tary[temp]=time;
            if(getchar()&&(c=getchar())=='y') ary[temp]++;
            else ary[temp]+=2;
            if(ary[temp]==2||(ary[temp]==3&&c=='r')){printf("%s %d %d\n",sa,temp,time);flag=1;}
        }
    }
    if(flag)putchar('\n');                  //题目上说存在不输出的情况。
    return 0;


}
/*从一开始就一直出在printf前面那个判断条件上面。一开始我的判断条件是hom[temp]>=2,结果考虑到
红牌不可能出很多张,所以我猜测一张就下场。。
结果就hom[temp]==2||hom[temp]==3,结果考虑到有可能会出现一张红加一张黄就会报两次,然后又看了题目。
只输出第一次红牌情况就可以了我就对if条件处理成om[temp]==2||(hom[temp]==3&&c=='r',然后就AC了,看有的人代码。
又创了一个新的数组记录次数,超过一次就continue,所以我觉得我这个处理还是不错的。*/

你可能感兴趣的:(493A Vasya and Football)