codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

493A.md (2486B)


      1 Source: https://codeforces.com/problemset/problem/493/A
      2 
      3 A. Vasya and Football
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 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.
     24 
     25 Input
     26 
     27 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.
     28 
     29 Next follows number *n* (1 ≤ *n* ≤ 90) — the number of fouls.
     30 
     31 Each of the following *n* lines contains information about a foul in the following form:
     32 
     33 * first goes number *t* (1 ≤ *t* ≤ 90) — the minute when the foul occurs;
     34 * 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;
     35 * then goes the player's number *m* (1 ≤ *m* ≤ 99);
     36 * 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.
     37 
     38 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.
     39 
     40 Output
     41 
     42 For each event when a player received his first red card in a chronological order print a string containing the following information:
     43 
     44 * The name of the team to which the player belongs;
     45 * the player's number in his team;
     46 * the minute when he received the card.
     47 
     48 If no player received a card, then you do not need to print anything.
     49 
     50 It is possible case that the program will not print anything to the output (if there were no red cards).
     51 
     52 Examples
     53 
     54 Input
     55 
     56 ```
     57 MC  
     58 CSKA  
     59 9  
     60 28 a 3 y  
     61 62 h 25 y  
     62 66 h 42 y  
     63 70 h 25 y  
     64 77 a 4 y  
     65 79 a 25 y  
     66 82 h 42 r  
     67 89 h 16 y  
     68 90 a 13 r
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 MC 25 70  
     75 MC 42 82  
     76 CSKA 13 90
     77 ```