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\ ...
随机推荐
- Lucene 排序 Sort与SortField
在sql语句中,有升序和降序排列.在Lucene中,同样也有. Sort里的属性 SortField里的属性 含义 Sort.INDEXORDER SortField.FIELD_DOC 按照索引的顺 ...
- PAT_1008 数组元素循环右移问题
题目描述: 一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0A1……AN-1)变换为(AN-M …… AN ...
- pc110301QWERTYU
水题一道,SOLVED只是次数的问题.map一下,就是很easy啦. #include<iostream> #include<cstdio> #include<cstri ...
- div section article aside的理解
div 是一个大的容器 内部可以包含header main nav aside footer等标签 没有语义,多用于为脚本添加样式 section的语义比div语义强些,用于主题性比较强的内容,比如一 ...
- 推荐用于格式化以及高亮显示SQL文的PHP类-SqlFormatter
有时候做开发用到SQL文的时候,由于sql文太长,很难真正看清楚这个sql文的结构. 所以需要一个工具能够自动对SQL文进行排版,在网上有幸找到这个用php写的类能处理这个任务. 原文地址是http: ...
- C#转义字符总结
转义字符 \·一种特殊的字符常量:·以反斜线"\"开头,后跟一个或几个字符.·具有特定的含义,不同于字符原有的意义,故称“转义”字符.·主要用来表示那些用一般字符不便于表示的控制代 ...
- Contest 20141027 总结
这次考试主要问题出在第一题,由于考试期间没有看清题意,少看了一句 “a=A/1e9" 导致在考试结束最后5分钟发现时修改过于匆忙,改出问题了.另外,这道题同时告诉我long double 在 ...
- MySQL协议简单分析
tcpdump -i eth0 -s0 -l -w - port 3306|strings|grep -i -E 'select|update|insert|delete|set'
- RESTful, 说说 http 的 patch method
最早的时候,我们只需要 GET 和 POST 方法,POST 方法的引入也只是为了消除 URL 过长,参数隐藏,上传文件的问题,完全和语义无关.接触到 RESTful 之后,我们开始思考 GET 和 ...
- C语言的static和extern关键字
我的博客:www.while0.com 如果A.c要包含B.c里的一个变量或函数,则在A.c中要用extern关键字声明.注意: ①如果是包含的B.c里的函数,则在A.c里声明的时候可以不写exter ...