cf493A
Description
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.
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 Input
MCCSKA928 a 3 y62 h 25 y66 h 42 y70 h 25 y77 a 4 y79 a 25 y82 h 42 r89 h 16 y90 a 13 r
MC 25 70MC 42 82CSKA 13 90
#include <stdio.h> #include <iostream> #include <string.h> using namespace std; bool visitAA[100]; bool visitBB[100]; struct Node { int shijian; int fenshu; }; Node AA[100]; Node BB[100]; int main() { string A,B; cin >> A >> B; memset(visitAA,false,sizeof(visitAA)); memset(visitBB,false,sizeof(visitBB)); int T; cin >> T; for(int i = 0 ; i < T; i++) { int Time; char team; int teamnum; char card; cin >> Time >> team >> teamnum >> card; if (team == 'a') { if (visitAA[teamnum]) { continue; } AA[teamnum].shijian = Time; if (card == 'y') { AA[teamnum].fenshu += 1; } else { AA[teamnum].fenshu += 2; } if (AA[teamnum].fenshu >= 2) { visitAA[teamnum] = true; cout << B << ' ' << teamnum << ' '<< Time << endl; } } else { if (visitBB[teamnum]) { continue; } BB[teamnum].shijian = Time; if (card == 'y') { BB[teamnum].fenshu += 1; } else { BB[teamnum].fenshu += 2; } if (BB[teamnum].fenshu >= 2) { visitBB[teamnum] = true; cout << A << ' ' << teamnum << ' '<< Time << endl; } } } }
cf493A的更多相关文章
- cf493A Vasya and Football
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- CF493A Vasya and Football 题解
Content 有两个球队在踢足球,现在给出一些足球运动员被黄牌或红牌警告的时间,求每个队员第一次被红牌警告的时间. 注意:根据足球比赛规则,两张黄牌自动换成一张红牌. 数据范围:比赛时间 \(90\ ...
随机推荐
- cocos2dx入门分析 hello world
打开新建的"findmistress"项目,可以看到项目文件是由多个代码文件及文件夹组成的,其中 Hello World 的代码文件直接存放于该项目文件夹中.下面我们来详细介绍一下 ...
- Python:模块引用
#!/usr/bin/python3 #Filename function.py #导入模块 import sys #导入function.py#function.py 文件import functi ...
- 《paste命令》-linux命令五分钟系列之二十
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...
- ERP系统开发平台 (C#语言,支持多数据库)
C/S系统开发框架-企业版 V4.0 (Enterprise Edition) 简介: http://www.csframework.com/cs-framework-4.0.htm 适用软件:适合开 ...
- Installing MySQL Server
Installing MySQL Server Here we will learn how to Compile and Install the MySQL Server from source c ...
- GIF文件转换为头文件工具
目的: GIF文件转为头文件 举例: 用UE打开GIF文件,如下图所示:图1 test.gif文件将上面文件内容转化为头文件,放到一个数组里面,内容如下:图2 test.h文件 思路: 从上面可知,将 ...
- mongodb常用命令【转】
mongodb由 C++编写,其名字来自humongous这个单词的中间部分,从名字可见其野心所在就是海量数据的处理.关于它的一个最简洁描述为:scalable, high-performance, ...
- js optimization and performance
http://www.codeproject.com/Articles/551733/Walkthrough-3aplusUsingplustheplusRequireJSplusOpt http:/ ...
- Dining
poj3281:http://poj.org/problem?id=3281 题意:有n个人,然后有F份食物,D份饮料,然后每一个会有一些喜爱的饮料和食物,问你最多可以使得多少人同时得到一份自己喜爱的 ...
- ibatis 中isNull, isNotNull与isEmpty, isNotEmpty区别
在iBATIS中isNull用于判断参数是否为Null,isNotNull相反 isEmpty判断参数是否为Null或者空,满足其中一个条件则其true isNotEmpty相反,当参数既不为Null ...