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

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
Output
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的更多相关文章

  1. cf493A Vasya and Football

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. CF493A Vasya and Football 题解

    Content 有两个球队在踢足球,现在给出一些足球运动员被黄牌或红牌警告的时间,求每个队员第一次被红牌警告的时间. 注意:根据足球比赛规则,两张黄牌自动换成一张红牌. 数据范围:比赛时间 \(90\ ...

随机推荐

  1. Codevs 1010 过河卒 2002年NOIP全国联赛普及组

    1010 过河卒 2002年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 传送门 题目描述 Description 如图,A 点有一个过河卒 ...

  2. SQL70001: This statement is not recognized in this context.

    关于错误: SQL70001: This statement is not recognized in this context. 的产生原因以及解决办法.   在SQL Server Databas ...

  3. StringBuilder字符串拼接类

    StringBuilder StringBuilder是在using System.Text命名空间下的一个成员. 在做字符串拼接的时候,因为字符串是引用类型,新的字符串是会再内存中创建的,所以用+号 ...

  4. javascrip 分享到

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. React 学习资源分享 菜鸟刚学5天 博客写的不多 不懂写博客的套路

    http://www.ruanyifeng.com/blog/2015/03/react.html 首先个人强烈推荐 阮一峰的React基础 细细过一遍,看得出大师的用心良苦 然后就开始看书般的过ht ...

  6. 请大神帮忙解决 jquery 控制 li 标签问题

    <li class="active"><a href="#1" data-toggle="tab">日志详细情况&l ...

  7. nutch-1.7 编译

    转载自:http://peigang.iteye.com/blog/1563288 从nutch-.3开始 本地抓取(单击) 和 分布式抓取(集群)所使用的配置文件和命令单独分开. 资源:下载地址:h ...

  8. Cow Contest

    poj3660:http://poj.org/problem?id=3660 题意:一些奶牛之间进行编程比赛,每头牛都有一个编程能力.如果a的能力比b的能力高,则a总能打败b .现在给你一些牛之间的比 ...

  9. hdu 5067 Harry And Dig Machine

    http://acm.hdu.edu.cn/showproblem.php?pid=5067 思路:问题可以转化成:从某一点出发,遍历网格上的一些点,每个点至少访问一次需要的最小时间是多少.这就是经典 ...

  10. Ajaxupload插件超级简单使用(php的ci框架)

                         Ajaxupload简单使用  友情提示:1.蓝色文字为必修改内容.2.#字符后面是解释该代码段的主要内容  备注: 该实例是用php的ci框架直接接收图片并 ...