Codeforces Round #281 (Div. 2) A 模拟
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 the firstmoment 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
题意::给犯规球员两种惩罚:一是黄牌,二是红牌。黄牌两次等同于红牌,红牌一次就判下场。现在给出两个队球员的惩罚情况,输出被罚红牌的球员所在的球队、球员编号和被罚下的时间
题解:模拟,注意细节
//code by drizzle
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
//#define ll long long
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
struct node
{
int time;
char group;
int num;
char card;
}N[];
struct gg
{
char group;
int time;
int num;
}ans[];
bool cmp(struct node aa,struct node bb)
{
return aa.time<bb.time;
}
map<char,map<int,int > >mp;
char a[];
char b[];
int n;
int main()
{
scanf("%s",a);
scanf("%s",b);
scanf("%d",&n);
mp.clear();
for(int i=;i<=n;i++)
scanf("%d %c %d %c",&N[i].time,&N[i].group,&N[i].num,&N[i].card);
sort(N+,N++n,cmp);
int jishu=;
for(int i=;i<=n;i++)
{
if(N[i].card=='r')
{
if(mp[N[i].group][N[i].num]>=)
{
ans[jishu].group=N[i].group;
ans[jishu].num=N[i].num;
ans[jishu].time=N[i].time;
jishu++;
mp[N[i].group][N[i].num]=-;
}
}
if(N[i].card=='y')
mp[N[i].group][N[i].num]++;
if(mp[N[i].group][N[i].num]==)
{
ans[jishu].group=N[i].group;
ans[jishu].num=N[i].num;
ans[jishu].time=N[i].time;
jishu++;
mp[N[i].group][N[i].num]=-;
}
}
for(int i=;i<jishu;i++)
{
if(ans[i].group=='h')
cout<<a;
else
cout<<b;
printf(" %d %d\n",ans[i].num,ans[i].time);
}
return ;
}
Codeforces Round #281 (Div. 2) A 模拟的更多相关文章
- Codeforces Round #281 (Div. 2) B 模拟
B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 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(模拟)
简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...
- Codeforces Round #249 (Div. 2) (模拟)
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- 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) 解题报告
题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...
- Codeforces Round #281 (Div. 2) D(简单博弈)
题目:http://codeforces.com/problemset/problem/493/D 题意:一个n*n的地图,有两个人在比赛,第一个人是白皇后开始在(1,1)位置,第二个人是黑皇后开始在 ...
随机推荐
- Charles拦截请求
一.通过Charles抓包,可拦截请求并篡改交互信息 1.可篡改客户端向服务器发起的请求信息(服务器收到的是假消息) 2.可篡改服务器返回给客户端的响应结果(客户端看到的是假消息) 二.篡改用户请求 ...
- latex目录标题常用宏包说明与示例
http://blog.sina.com.cn/s/blog_5e16f1770100gyxn.html
- windows 安装nodejs及配置服务
一.什么是nodejs Node.js是一个Javascript运行环境(runtime).实际上它是对Google V8引擎进行了封装.V8引 擎执行Javascript的速度非常快,性能非常好.N ...
- Sum All Primes-freecodecamp算法题目
Sum All Primes 1.要求 求小于等于给定数值的质数之和. 只有 1 和它本身两个约数的数叫质数.例如,2 是质数,因为它只能被 1 和 2 整除.1 不是质数,因为它只能被自身整除. 2 ...
- 【搜索】【入门】洛谷P1036 选数
题目描述 已知 n个整数x1,x2,…,xn,以及1个整数k(k<n).从nn个整数中任选kk个整数相加,可分别得到一系列的和. 例如当n=4,k=3,4个整数分别为3,7,12,19时, ...
- js函数带括号和不带括号赋给对象属性的区别
注意: 1.js为对象添加函数时,不要在函数后面加().一旦加了括号是表示将函数的返回值赋给对象的属性. 例:function test(){ document.writeln("我是js函 ...
- Java - 若try中有return语句,finally会执行吗?在return之前还是之后呢?
会执行,在方法return动作之前,return语句执行之后,若finally中再有return语句,则此方法以finally的return作为最终返回,若finally中无return语句,则此方法 ...
- 5-3 time模块
1.取当前时间戳和当前格式化时间 import time1 # 以时间戳的形式打印当前时间 1543849862 print(int(time.time()))#时间戳 # 取当前格式化好的时间 20 ...
- shell数组脚本
#!/bin/bash array=( ) ;i<${#array[*]};i++)) do echo ${array[i]} done 脚本2 #!/bin/bash array=( ) fo ...
- 详解 JS 中 new 调用函数原理
JavaScript 中经常使用构造函数创建对象(通过 new 操作符调用一个函数),那在使用 new 调用一个函数的时候到底发生了什么?先看几个例子,再解释背后发生了什么. 1)看三个例子 1.1 ...