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)位置,第二个人是黑皇后开始在 ...
随机推荐
- java基础编程——用两个栈来实现一个队列
题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 题目代码 /** * <分析>: * 入队:将元素进栈A * 出队:判断栈B是否为空, * ...
- 第十三篇、OC_UICollectionView的基本配置
- (UICollectionView *) categoryCollectionView { if (! _categoryCollectionView) { // 创建布局 UICollectio ...
- antd-design-pro 服务代理问题
公司希望又一个后台管理页面.因为之前技术栈是react 所以选择了antd-design-pro作为后台的框架. 在连调api的时候,困惑怎么去代理.因为网上查到很多都是1.0的版本,而我现在用的是2 ...
- Atlas 配置高可用
keepalived安装 #下载keepalived ./configure --prefix=/usr/local Make && make install Atlas主安装keep ...
- 三十、MySQL 处理重复数据
MySQL 处理重复数据 有些 MySQL 数据表中可能存在重复的记录,有些情况我们允许重复数据的存在,但有时候我们也需要删除这些重复的数据. 本章节我们将为大家介绍如何防止数据表出现重复数据及如何删 ...
- 整合mybatis和spring时 Error creating bean with name 'sqlSessionFactory' defined in class path resource
今天在整合mybatis和spring的时候出的错 报错如下 Exception in thread "main" org.springframework.beans.factor ...
- LeetCode#5 两个排序数组的中位数
给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 . 请找出这两个有序数组的中位数.要求算法的时间复杂度为 O(log (m+n)) . 你可以假设 nums1 和 nums2 ...
- GBK UTF8 GB2132
GBK就是在保存你的帖子的时候,一个汉字占用两个字节,外国人看会出现乱码,为此我中华为自己汉字编码而形成之解决方案. UTF8就是在保存你的帖子的时候,一个汉字占用3个字节.但是外国人看的话不会乱码. ...
- 【104】Maven3.5.0结合eclipse使用,提示Lambda expressions are allowed only at source level 1.8 or above错误的解决方法
错误重现 我的机器上安装了 maven 3.5.0,在 eclipse 中创建 maven 项目.pom.xml配置如下: <project xmlns="http://maven.a ...
- django开发傻瓜教程-1-安装和HelloWorld
安装 sudo pip install Django 新建项目 django-admin startproject XXX 启动项目 进入主目录下 python manage.py runserver ...