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\ ...
随机推荐
- [转]toString()方法
文章转自:http://blog.sina.com.cn/s/blog_85c1dc100101bxgg.html 今天看JS学习资料,看到一个toString()方法,在JS中,定义的所有对象都具有 ...
- Java 设计模式_代理模式(2016-08-19)
概念: 代理模式是对象的结构模式.代理模式给某一个对象提供一个代理对象,并由代理对象控制对原对象的引用. 就是一个人或者机构代表另一个人或者机构采取行动.在一些情况下,一个客户不想或者不能够直接引用一 ...
- Linux的more、less
2.more 文件内容或输出查看工具: more 是我们最常用的工具之一,最常用的就是显示输出的内容,然后根据窗口的大小进行分页显示,然后还能提示文件的百分比: de>[root@localho ...
- 读书笔记之 - javascript 设计模式 - 享元模式
本章探讨另一种优化模式-享元模式,它最适合于解决因创建大量类似对象而累及性能的问题.这种模式在javascript中尤其有用,因为复杂的javascript代码很快就会用光浏览器的所有可用内存,通过把 ...
- sublime 正则搜索日语字符
sublime 正则搜索日语字符 [\x{3041}-\x{3096}\x{30A0}-\x{30FF}\x{3400}-\x{4DB5}\x{4E00}-\x{9FCB}\x{F900}-\x{FA ...
- Dice (III) 概率dp
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> ...
- thinkphp3.2 namespace及use用法
PHP 5.3中的namespace其实是个不错的东西,可以简化编程,下面介绍三类在代码中 访问namespace中类的方法 1 引用namespace和类 假设namespace的程序为name ...
- linux下date命令实现时间戳与日期的转换
1.查看指定时间的时间戳 查看当前时间 #date +%s 查看指定时间 #date -d 2008-01-01 +%s 1199116800 #date -d 20080101 ...
- build tree
有二叉树的前序遍历和后序遍历,构造二叉树 /** * Definition for binary tree * public class TreeNode { * int val; * TreeNod ...
- Codeforces Round #313 (Div. 2)
大半年没有打Codeforces , 昨天开始恢复打Codeforces, 简直是, 欲语泪先流啊. 手残到爆的写错了范围, 手残的数漏了条件, 简直不能直视, 最坑爹的是, E题没时间写代码了. 题 ...