A. Vasya and Football
2 seconds
256 megabytes
standard input
standard output
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 thefirst moment of time when he would receive a red card from Vasya.
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.
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).
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
MC 25 70
MC 42 82
CSKA 13 90
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std; int b[100], c1[110], c2[110], c3[110], c4[110]; struct node {
int t;
char c;
int m;
char d;
}a[100]; int cmp(node a, node b) {
return a.t < b.t;
} int main() {
string str1, str2;
cin >> str1 >> str2;
int n;
cin >> n;
memset(a, 0, sizeof(a)); for (int i = 0; i < n; i++)
cin >> a[i].t >> a[i].c >> a[i].m >> a[i].d;
sort(a, a + n, cmp); memset(b, 0, sizeof(b));
memset(c1, 0, sizeof(c1));
memset(c2, 0, sizeof(c2));
memset(c3, 0, sizeof(c2));
memset(c4, 0, sizeof(c2));
int num = 0;
//int flag1 = 0, flag2 = 0;
for (int i = 0; i < n; i++) {
if (a[i].d == 'r' && a[i].c == 'h' && c3[a[i].m] == 0) {
b[num++] = i;
c3[a[i].m] ++; }
else if (a[i].d == 'r' && a[i].c == 'a' && c4[a[i].m] == 0) {
b[num++] = i;
c4[a[i].m] ++; } else if (a[i].d == 'y' && c1[a[i].m] == 1 && a[i].c == 'h' && c3[a[i].m] == 0) {
b[num++] = i;
c3[a[i].m] ++;
}
else if (a[i].d == 'y' && c2[a[i].m] == 1 && a[i].c == 'a' && c4[a[i].m] == 0) {
b[num++] = i;
c4[a[i].m] ++;
}
else if (a[i].d == 'y' && a[i].c == 'h')
c1[a[i].m] ++;
else if (a[i].d == 'y' && a[i].c == 'a')
c2[a[i].m] ++;
}
for (int i = 0; i < num; i++) {
if (a[b[i]].c == 'h')
cout << str1 << " " << a[b[i]].m << " " << a[b[i]].t << endl;
else
cout << str2 << " " << a[b[i]].m << " " << a[b[i]].t << endl;
}
return 0;
}
A. Vasya and Football的更多相关文章
- cf493A Vasya and Football
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟
A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has starte ...
- 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 ...
- 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 ...
- codeforces 493A. Vasya and Football 解题报告
题目链接:http://codeforces.com/contest/493/problem/A 题目意思:给出两个字符串,分别代表 home 和 away.然后有 t 个player,每个playe ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)
简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...
- CF493A Vasya and Football 题解
Content 有两个球队在踢足球,现在给出一些足球运动员被黄牌或红牌警告的时间,求每个队员第一次被红牌警告的时间. 注意:根据足球比赛规则,两张黄牌自动换成一张红牌. 数据范围:比赛时间 \(90\ ...
- Codeforces Round #281 (Div. 2)
题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football gam ...
- Codeforces Round #281 (Div. 2) A 模拟
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
随机推荐
- jquery UI autocomplete当输入框焦点聚焦时自动弹出跟随下拉框
$("#search").autocomplete({ minLength: 0, source: function(request,response){ // request对象 ...
- php-递归创建级联目录
方法一: function mk_dir($path_arr,$root){ if(!empty($path_arr)){ static $path;//每次保存上次调用的值 $path .= '/' ...
- override与重载(overload)的区别
重载是相同函数名字.参数或参数类型不同,进行多次承载以适应不同的需要.(orerload)是面向过程的重载. (override)是面向对象的重载.是进行基类中的函数重写.
- a 标签的四种样式
在支持 CSS 的浏览器中,链接的不同状态都可以不同的方式显示,这些状态包括:活动状态,已被访问状态,未被访问状态,和鼠标悬停状态.分别如下设置: a:link {color: red} /* 未访问 ...
- 麻瓜之我要学sql,啦啦啦啦
四张表 学生表:编号,姓名,性别,班级,生日 CREATE TABLE IF NOT EXISTS student( sno TINYINT UNSIGNED NOT NULL, sname ) NO ...
- thinkphp3.2.3的使用心得(零)
从模板传参到控制器 模板中代码: <volist name="list" id="vo"> <a href="__CONTROLLE ...
- Linux 多线程下载工具:axel
wget 应该是最常用的下载工具了,但是其不支持多线程下载. axel 安装 epel 源有 axel 的二进制包,可以使用 yum 安装. yum install epel-release yum ...
- 正确显示textarea中输入的回车和空格
在textarea中输入的文本.如果含有回车或空格.在界面上显示的时候则不那么正常.回车消失了,空格变短了. 如何解决这个问题呢.有2种方法. 1.使用<pre>标签 w3c对pre元素是 ...
- 前端工程之CDN部署
之前发的一篇文章<变态的静态资源缓存与更新>中提到了静态资源和页面部署之间的时间间隙问题,这个问题会迫使前端静态资源发布必须采用非覆盖式. 那篇文章中没有详细解释为什么会产生不可忍受的时间 ...
- Python可视化库Matplotlib的使用
一.导入数据 import pandas as pd unrate = pd.read_csv('unrate.csv') unrate['DATE'] = pd.to_datetime(unrate ...