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 ...
随机推荐
- MySQL时间操作的系统函数用法
我要查询获得当天凌晨30分的datetime值的方式:select ADDDATE(CURDATE(), INTERVAL TIME_TO_SEC(TIMEDIFF("00:30:00&qu ...
- 什么是副作用(Side Effect)
副作用(Side Effect)是指函数或者表达式的行为依赖于外部世界.具体可参照Wiki上的定义,副作用是指 1)函数或者表达式修改了它的SCOPE之外的状态 2)函数或者表达式除了返回语句外还与外 ...
- 读Zepto源码之assets模块
assets 模块是为解决 Safari 移动版加载图片过大过多时崩溃的问题.因为没有处理过这样的场景,所以这部分的代码解释不会太多,为了说明这个问题,我翻译了<How to work arou ...
- 搭建和测试 Redis 主备和集群
本文章只是自我学习用,不适宜转载. 1. Redis主备集群 1.1 搭建步骤 机器:海航云虚机(2核4GB内存),使用 Centos 7.2 64bit 操作系统,IP 分别是 192.168.10 ...
- lesson - 9 课程笔记
一. yum 作用: yum 命令是在Fedora 和RedHat 以及SUSE 中基于rpm 的软件包管理器,它可以使系统管理人员交互和自动 ...
- ActiveMQ (一) 初识ActiveMQ
了解JMS JMS即Java消息服务(Java Message Service)应用程序接口是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进 ...
- win10大水牛主机插入耳机没有声音
主机:大水牛,技嘉主板 操作系统:win10 问题:主机前面插入耳机,没有声音,扬声器图标出错 解决 一..插入耳机 二..Realtek高清晰音频管理器 1.打开音频管理器,点击右下角的设置 2.点 ...
- python爬虫爬取大众点评并导入redis
直接上代码,导入redis的中文编码没有解决,日后解决了会第一时间上代码!新手上路,多多包涵! # -*- coding: utf-8 -*- import re import requests fr ...
- 浏览器中的user-agent的几种模式
服务器一般会根据访问的浏览器进行识别,针对不同浏览器才用不同的网站样式及结构,也是通过这个信息判断用户使用的平台模式(手机,pc或平板) 识别为手机一般有这几个关键字: "Windows P ...
- vlc源码研究
有位传说中的大神告诉我,我的p2p打洞打不通是因为,sdp描述信息中的地址不对 也就是IN IP4 XXX.XXX.X.XXX这一句 我看到确实是个局域网地址,那么vlc在接收到IN IP4 XXX. ...