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 firstmoment of time when he would receive a red card from Vasya.
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.
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).
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
MC 25 70
MC 42 82
CSKA 13 90
题意::给犯规球员两种惩罚:一是黄牌,二是红牌。黄牌两次等同于红牌,红牌一次就判下场。现在给出两个队球员的惩罚情况,输出被罚红牌的球员所在的球队、球员编号和被罚下的时间
题解:模拟,注意细节
1 //code by drizzle 2 #include<bits/stdc++.h> 3 #include<iostream> 4 #include<cstring> 5 #include<cstdio> 6 #include<algorithm> 7 #include<vector> 8 #include<queue> 9 #include<stack> 10 //#define ll long long 11 #define ll __int64 12 #define PI acos(-1.0) 13 #define mod 1000000007 14 using namespace std; 15 struct node 16 { 17 int time; 18 char group; 19 int num; 20 char card; 21 }N[105]; 22 struct gg 23 { 24 char group; 25 int time; 26 int num; 27 }ans[105]; 28 bool cmp(struct node aa,struct node bb) 29 { 30 return aa.time<bb.time; 31 } 32 map<char,map<int,int > >mp; 33 char a[25]; 34 char b[25]; 35 int n; 36 int main() 37 { 38 scanf("%s",a); 39 scanf("%s",b); 40 scanf("%d",&n); 41 mp.clear(); 42 for(int i=1;i<=n;i++) 43 scanf("%d %c %d %c",&N[i].time,&N[i].group,&N[i].num,&N[i].card); 44 sort(N+1,N+1+n,cmp); 45 int jishu=0; 46 for(int i=1;i<=n;i++) 47 { 48 if(N[i].card=='r') 49 { 50 if(mp[N[i].group][N[i].num]>=0) 51 { 52 ans[jishu].group=N[i].group; 53 ans[jishu].num=N[i].num; 54 ans[jishu].time=N[i].time; 55 jishu++; 56 mp[N[i].group][N[i].num]=-10000; 57 } 58 } 59 if(N[i].card=='y') 60 mp[N[i].group][N[i].num]++; 61 if(mp[N[i].group][N[i].num]==2) 62 { 63 ans[jishu].group=N[i].group; 64 ans[jishu].num=N[i].num; 65 ans[jishu].time=N[i].time; 66 jishu++; 67 mp[N[i].group][N[i].num]=-10000; 68 } 69 } 70 for(int i=0;i<jishu;i++) 71 { 72 if(ans[i].group=='h') 73 cout<<a; 74 else 75 cout<<b; 76 printf(" %d %d ",ans[i].num,ans[i].time); 77 } 78 return 0; 79 }