当前位置:   article > 正文

A. Vasya and Football_vasya has started watching football games. he has

vasya has started watching football games. he has learned that for some foul

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

解题说明:题目意思是给出两个字符串,分别代表 home 和 away。然后有 t个player,每个player偶四个属性描述:分钟,所属的队名(即上面的两个字符串的其中一个),该player的num,得到的card颜色(y/r)。 当一个人得到两个y card 时会自动转为 r card。最终需要按时间先后的顺序输出player第一次获得red card 的时间。由于数据是按时间先后顺序排列的,那么对于某个player,如果得到 r card,就可以直接输出答案了。然后得到 y card,要先用vis数组记录,如果再次遇到该player 且 vis数组已经被标记,那么这个player 符合条件,直接输出答案。注意,输出答案之后要标记这个player已经被处理。


  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cstring>
  5. #include<string>
  6. #include<cmath>
  7. #include<cstdlib>
  8. using namespace std;
  9. char as[100], ar[100], te[100];
  10. int t1[100], t2[100];
  11. int main()
  12. {
  13. int i, j, k, n, a, b, c;
  14. char c1,c2;
  15. scanf(" %s %s",ar,as);
  16. scanf(" %d",&n);
  17. for(i=0;i<n;i++)
  18. {
  19. scanf(" %d %c %d %c",&a,&c1,&b,&c2);
  20. if(c1=='h')
  21. {
  22. if(t1[b]>=2)
  23. {
  24. continue;
  25. }
  26. if(c2=='y')
  27. {
  28. t1[b]++;
  29. }
  30. else
  31. {
  32. t1[b]+=2;
  33. }
  34. if(t1[b]>=2)
  35. {
  36. printf("%s %d %d\n",ar,b,a);
  37. }
  38. }
  39. else
  40. {
  41. if(t2[b]>=2)
  42. {
  43. continue;
  44. }
  45. if(c2=='y')
  46. {
  47. t2[b]++;
  48. }
  49. else
  50. {
  51. t2[b]+=2;
  52. }
  53. if(t2[b]>=2)
  54. {
  55. printf("%s %d %d\n",as,b,a);
  56. }
  57. }
  58. }
  59. return 0;
  60. }


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/75105
推荐阅读
相关标签
  

闽ICP备14008679号