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. sh脚本学习之: 命令处理

    输出 默认是命令行输出 > 替换输出 >> append输出 2>  错误输出 < 由文件输入 <<eof 控制台输入,eof为输入结束标志 /dev/nul ...

  2. 格式化 SQL 来提高效率

    本文由 伯乐在线 - cucr 翻译,黄利民 校稿.未经许可,禁止转载!英文出处:msiman.ga.欢迎加入翻译小组. 背景 已格式化的SQL并不比未格式化SQL运行地更快.数据库可能真的不太在意你 ...

  3. JavaScript编写风格指南 (一)

    //参考<编写可维护的Javascript>  一:缩进// 第一行的层级由4个空格组成,避免使用制表符tab进行缩进 //好的写法if (true) {    doSomething() ...

  4. [机器学习&数据挖掘]SVM---核函数

    1.核函数概述: 核函数通俗的来说是通过一个函数将向量的低维空间映射到一个高维空间,从而将低维空间的非线性问题转换为高维空间的线性问题来求解,从而再利用之前说的一系列线性支持向量机,常用的核函数如下: ...

  5. Hive笔记之Fetch Task

    在使用Hive的时候,有时候只是想取表中某个分区的前几条的记录看下数据格式,比如一个很常用的查询: select * from foo where partition_column=bar limit ...

  6. Wordpress页脚

    <?php /** * The template for displaying the footer */ ?> <?php if ( apply_filters( 'show_fl ...

  7. 简单解读linux的/proc下的statm、maps、memmap 内存信息文件分析【转】

    转自:https://blog.csdn.net/sctq8888/article/details/7398776 转载自:http://hi.baidu.com/deep_pro/blog/item ...

  8. 阿里云RDS的mysql数据库占用空间超过90%的处理

    阿里云RDS数据库最大支持2T,目前已经占用了90%,如果进行分库或者迁移比较麻烦,思路是找出占用空间过大的日志或不重要的文件进行删除操作 查询所有数据库占用磁盘空间大小的SQL语句: show bi ...

  9. MAVEN:不能互相引用

    工程A,工程B,工程C,这三个工程:C依赖B,B依赖A,这是没有问题的. 但是不能A依赖B,B又依赖A,这是不允许的.

  10. html复习之标签整理

    <body>标签,网页上显示的内容放在这里开始学习<p>标签,添加段落<hx>标签,为网页添加标题加入强调语气,使用<strong>加粗和<em& ...