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. Win32中GDI+应用(二)--初始化与清理

    GDI+提供了GdiplusStartup和 GdiplusShutdown 函数来进行初始化和完成清理工作.你必须在调用其他的GDI+函数之前,调用GdiplusStartup函数,在完成GDI+工 ...

  2. 更改css element.style

    样式后面加 !important就可以更改element.style的优先级了

  3. jquery live()只支持css选择器

    昨天在处理过keypress键盘事件后,今天要把用户在页面上动态添加的字段条目加上删除功能,就是在每个字段后面加上一个漂亮的小按钮,当用户点击这个按钮,相应的条目就被从数据库中删除. 为了实现这种功能 ...

  4. HTML+JS版本的俄罗斯方块

    <!doctype html><html><head></head><body> <div id="box" st ...

  5. 各大Oj平台介绍[转]

    1.题库与网站资源题库-在线提交系统(Online Judge)简介   下面是几个比较大的在线提交系统(OnlineJudge)里面有大量历年的竞赛题目,注册一个ID,然后用自己熟悉的语言(一般有P ...

  6. bzoj 1223: [HNOI2002]Kathy函数 数位DP 高精度

    1223: [HNOI2002]Kathy函数 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 207  Solved: 90[Submit][Stat ...

  7. 【Java】WEB-INF目录与META-INF目录的作用

    /WEB-INF/web.xml Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则. /WEB-INF/classes/包含了站点所有用的 class 文件,包括 ser ...

  8. Sed&awk笔记之awk篇

    http://blog.csdn.net/a81895898/article/details/8482333 Awk是什么 Awk.sed与grep,俗称Linux下的三剑客,它们之间有很多相似点,但 ...

  9. Alice's Chance

    poj1698:http://poj.org/problem?id=1698 题意:爱丽丝要拍电影,有n部电影,规定爱丽丝每部电影在每个礼拜只有固定的几天可以拍电影,只可以拍前面w个礼拜,并且这部电影 ...

  10. js中常用framesetiframe页面跳转传参方法实例大全

    logf的空间