A. Vasya and Football

题目连接:

http://codeforces.com/contest/493/problem/A

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 first moment 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

MC

CSKA

9

28 a 3 y

62 h 25 y

66 h 42 y

70 h 25 y

77 a 4 y

79 a 25 y

82 h 42 r

89 h 16 y

90 a 13 r

Sample Output

MC 25 70

MC 42 82

CSKA 13 90

Hint

题意

有两个球队在打比赛,然后现在给你每个球队的惩罚情况,让你输出拿红牌的情况。

题解:

模拟题

代码

#include<bits/stdc++.h>
using namespace std; int H[2][105];
vector<string> ans1;
vector<int> ans2,ans3;
int vis[2][105];
int main()
{
string s1,s2;
cin>>s1>>s2;
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int a,b;
string a1,b1;
cin>>a>>a1>>b>>b1;
int id;
if(a1=="a")id=0;
else id=1;
if(b1=="y")
{
H[id][b]++;
if(H[id][b]==2&&!vis[id][b])
{
if(id==0)ans1.push_back(s2);
else ans1.push_back(s1);
ans2.push_back(b);
ans3.push_back(a);
vis[id][b]=1;
}
}
else
{
H[id][b]=2;
if(H[id][b]==2&&!vis[id][b])
{
if(id==0)ans1.push_back(s2);
else ans1.push_back(s1);
ans2.push_back(b);
ans3.push_back(a);
vis[id][b]=1;
}
}
}
for(int i=0;i<ans1.size();i++)
cout<<ans1[i]<<" "<<ans2[i]<<" "<<ans3[i]<<endl;
}

Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟的更多相关文章

  1. Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)

    简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...

  2. Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力水题

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

  3. Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力

    A. Vasya and Football   Vasya has started watching football games. He has learned that for some foul ...

  4. Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题

    B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...

  5. Codeforces Round #281 (Div. 2) D. Vasya and Chess 水

    D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分

    C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. Codeforces Round #281 (Div. 2) D. Vasya and Chess 镜面对称 博弈论

    D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题

    C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈

    D. Vasya and Chess   Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...

  10. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序

    C. Vasya and Basketball   Vasya follows a basketball game and marks the distances from which each te ...

随机推荐

  1. 均方根值(RMS)+ 均方根误差(RMSE)+标准差(Standard Deviation)

    均方根值(RMS)+ 均方根误差(RMSE)+标准差(Standard Deviation)  1.均方根值(RMS)也称作为效值,它的计算方法是先平方.再平均.然后开方. 2.均方根误差,它是观测值 ...

  2. day63_SpringMVC学习笔记_01

    1.JAVAEE体系结构 JAVAEE体系结构图如下所示: 2.什么是springmvc? 什么是mvc? Model1 Model2 SpringMVC是什么? SpringMVC是一个web层mv ...

  3. jdk1.8.0_45源码解读——HashSet的实现

    jdk1.8.0_45源码解读——HashSet的实现 一.HashSet概述 HashSet实现Set接口,由哈希表(实际上是一个HashMap实例)支持.主要具有以下的特点: 不保证set的迭代顺 ...

  4. ASP.NET MVC学习(二)之控制器Controller

    1.控制器 Controller接收用户请求,将Model和View匹配在一起,共同完成用户请求.它是一个分发器,通过选择不同的Model.View,可以决定完成不同的用户请求. 但Controlle ...

  5. MYSQL查询重复记录的方法

    select * from hengtu_demandpush a where (a.did,a.mid) in (select did,mid from hengtu_demandpush grou ...

  6. 第5月第16天 php crud CodeIgniter CI_DB_active_record

    1.C.R.U.D. Generator for CodeIgniter https://github.com/antonioyee/crud-generator/tree/9e5e48e773a52 ...

  7. spring事务详解(一)初探讨

    一.什么是事务 维基百科:数据库事务(简称:事务)是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成.理解:事务(Transaction)是数据库区别于文件系统的重要特性之一.传 ...

  8. 【原创】Linux环境下的图形系统和AMD R600显卡编程(2)——Framebuffer、DRM、EXA和Mesa简介【转】

    转自:http://www.cnblogs.com/shoemaker/p/linux_graphics02.html 1. Framebuffer Framebuffer驱动提供基本的显示,fram ...

  9. 内存对齐与ANSI C中struct型数据的内存布局 【转】

    转自:http://blog.chinaunix.net/uid-25909619-id-3032209.html 当在C中定义了一个结构类型时,它的大小是否等于各字段(field)大小之和?编译器将 ...

  10. 局域网搭建https局域网

    局域网搭建https局域网 1.使用tomcat作为服务器搭建局域网访问https 需要使用java jdk\bin下的keytool.exe来创建证书 使用命令:keytool -genkenpai ...