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. Repeater 动态增加删除一行

    文章参考:文章参考http://www.cnblogs.com/dataadapter/archive/2012/06/25/2562885.html 效果: 前台代码: <%@ Page La ...

  2. 转: angularjs 指令中动态编译的方法(适用于有异步请求的情况) 内嵌指令无效

    angular的坑很多 例子: 在directive的link中有一个$http请求,当请求完成后根据返回的值动态做element.append('......');这个操作, 能显示没问题,可问题是 ...

  3. 《转》15种CSS混合模式让图片产生令人惊艳的效果

    浏览器支持 按照现在情况来讲, 浏览器支持 CSSbackground-blend-mode属性还在不断的完善中.早期版本的浏览器目前还不支持,但caniuse.com报告说在Chrome,Firef ...

  4. 【清橙A1084】【FFT】快速傅里叶变换

    问题描述 离散傅立叶变换在信号处理中扮演者重要的角色.利用傅立叶变换,可以实现信号在时域和频域之间的转换. 对于一个给定的长度为n=2m (m为整数) 的复数序列X0, X1, …, Xn-1,离散傅 ...

  5. [转]显示文件命令:cat、more、less、tail、touch详解

    cat命令cat命令连接文件并打印到标准输出设备上.cat经常用来显示文件的内容,类似于下的type命令. 一般格式:cat [选项] 文件说明:该命令有两项功能,其一是用来显示文件的内容,它依次读取 ...

  6. 关于手机端CSS Sprite图标定位的一些领悟

    今天在某个群里面闲逛,看见一个童鞋分享了一个携程的移动端的页面.地址这里我也分享下吧:http://m.ctrip.com/html5/在手机端我都很少用雪碧图合并定位图标,用的比较多就是用字体图标来 ...

  7. In Place Upgrade of CentOS 6 to CentOS 7

    Note: This is not the most highly recommended method to move from CentOS 6 to CentOS 7 ... but it ca ...

  8. [python]随机数

    import random()testlist = [1,3,4,5]a,b = 1,5random().random()() 生成0至1之间的随机浮点数,结果大于等于0.0,小于1.0random. ...

  9. 编程思想—面向切面编程(AOP)

    谈到面向切面的编程,我们很容易关联到面向对象编程(OOP).个人对这两种编程方式的解释为:两种编程思想只是站在编程的角度问题. OOP注重的是对象,怎么对对象行为和方法的抽象.如何封装一个具有完整属性 ...

  10. [原创]dm642_HPI调通并boot成功

    一直在折腾前段时间画好的dm642+lpc4357板子,说明下这个板子的结构: 主芯片为DM642,这个片子很老了,但因为对这个片子熟悉,别折腾 没有给DM642加FLASH,配了一片LPC4357, ...