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\ ...
随机推荐
- mysql修改字符集 转载
查看编码: show variables like 'collation_%'; show variables like 'character_set_%'; 修改: MySQ ...
- Windows phone 之XML序列化与反序列化
为什么要做序列化和反序列化? 一个回答: 我们都知道对象是不能在网络中直接传输的,不过还有补救的办法.XML(Extensible Markup Language)可扩展标记语言,本身就被设计用来存储 ...
- apache2.4配置虚拟主机
step1 启用 httpd-vhosts.conf 找到E:/apache/Apache24/conf 中httpd.conf 文件,取消注释下面这句话 step2 在 httpd-vhosts.c ...
- 将VIM配置成强大的IDE(三)
上一节,我们知道了,我们了解了怎么配置插件的下下载. 现在,我们就可以去DIY我们的IDE了,主要介绍taglist插件和NERDTree插件,最终的结果是: 1.安装Taglist插件. Tagli ...
- Python核心编程2第四章课后练习
4-1 Python 对象.与所有 Python 对象有关的三个属性是什么?请简单的描述一下. 身份:对象的唯一标识 类型 :对象的类型决定了该对象可以保存什么类型的值 ...
- 如何分析matlab程序的主要效率问题
利用profile on 在需要分析效率的程序段前后加入 profile on profile off 然后,在common line中输入profile viewer即可观察到这段程序的效率
- 在Windows下读取Ext4分区
转自在Windows下读取Ext4分区 本文介绍两个能在 Windows 下读取ext4分区的软件. 第一个是 Ext2Read.它能查看 ext2/3/4 分区并从中拷贝文件和目录,支持 LVM2 ...
- 【HDU2825】Wireless Password (AC自动机+状压DP)
Wireless Password Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u De ...
- h.264并行解码算法2D-Wave实现(基于多核非共享内存系统)
在<Scalable Parallel Programming Applied to H.264/AVC Decoding>书中,作者基于双芯片18核的Cell BE系统实现了2D-Wav ...
- bzoj3437
练一下斜率优化 ..] of int64; q,a,b:..] of longint; i,n,h,t,j:longint; function g(j,k:longint):double; var a ...