CF493A Vasya and Football 题解
Content
有两个球队在踢足球,现在给出一些足球运动员被黄牌或红牌警告的时间,求每个队员第一次被红牌警告的时间。
注意:根据足球比赛规则,两张黄牌自动换成一张红牌。
数据范围:比赛时间 \(90\) 分钟,足球员号码 \(\leqslant 99\)。
Solution
这道题目就是一个很纯粹的模拟。主要注意以下几点:
- 两个球队当中也许有相同号码的球员。比如说近现代的 \(10\) 号球员有很多,比如说齐达内和梅西等。
- 球员被红牌下场了,但后面还有可能会录入关于该球员的警告信息,此时应该忽略它。
考虑完这些,模拟就简单多了。
Code
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
string a, b;
int num_of_foul, ye[2][1007], vis[2][1007];
int main() {
	cin >> a >> b;
	scanf("%d", &num_of_foul);
	for(int i = 1; i <= num_of_foul; ++i) {
		int t_of_foul, num;
		char ha[2], yr[2];
		scanf("%d%s%d%s", &t_of_foul, ha, &num, yr);
		if(yr[0] == 'r' && (ha[0] == 'h' ? !vis[0][num] : !vis[1][num])){
			if(ha[0] == 'h')	cout << a << ' ';
			else if(ha[0] == 'a')	cout << b << ' ';
			printf("%d %d\n", num, t_of_foul);
			if(ha[0] == 'h')	vis[0][num] = 1;
			else if(ha[0] == 'a')	vis[1][num] = 1;
		} else if(yr[0] == 'y') {
			if(ha[0] == 'h')	ye[0][num]++;
			else if(ha[0] == 'a')	ye[1][num]++;
			if(ye[0][num] == 2 && !vis[0][num]) {
				cout << a << ' ';
				printf("%d %d\n", num, t_of_foul);
				vis[0][num] = 1;
			} else if(ye[1][num] == 2 && !vis[1][num]){
				cout << b << ' ';
				printf("%d %d\n", num, t_of_foul);
				vis[1][num] = 1;
			}
		}
	}
}
CF493A 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 Vasya has started watching football games. He has learned that for some foul ... 
- 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 time limit per test 2 seconds memory limit per test 256 megabytes input standa ... 
- 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这个词 ... 
- CF1082A Vasya and Book 题解
		Content 给定 \(T\) 组数据,每组数据给出四个整数 \(n,x,y,d\).小 V 有一本 \(n\) 页的书,每次可以恰好翻 \(d\) 页,求从第 \(x\) 页恰好翻到第 \(y\) ... 
- CF1036D Vasya and Arrays 题解
		Content 给定两个长度分别为 \(n\) 和 \(m\) 的数列 \(A,B\).你需要将两个数列都恰好分成 \(k\) 份,使得两个数列中第 \(i(i\in[1,k])\) 份的元素和对应相 ... 
随机推荐
- Semaphore信号量的使用
			package ThreadTest; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; pub ... 
- 【Azure 应用服务】App Service 无法连接到Azure MySQL服务,报错:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
			问题描述 App Service使用jdbc连接MySQL服务,出现大量的 Communications link failure: com.mysql.cj.jdbc.exceptions.Com ... 
- 【PS】证件照转换背景色
			证件照转换背景色 2019-07-14 12:18:49 by冲冲 1. 需求 自由切换证件照的背景颜色(白底.蓝底.红底...) 2. 步骤 ① 双击 图层锁 解锁,弹出的"新建图层0 ... 
- springboot和mybatis集成
			springboot和mybatis集成 pom <?xml version="1.0" encoding="UTF-8"?> <proje ... 
- Hbuilder/Uniapp 格式化的时候,很多属性会排列在一行,如何结局?
			因为自己遇到这个问题,然后百度了很久都得不到解决办法,所以解决问题以后在博客园写下此文,希望能帮助到更多人! //在jsbeautifyrc.js里面的html中加入这个,就OK了 "wra ... 
- Run For Beer CF575G
			Run for beer CF 575G 如果直接bfs分层贪心可以做,但是很毒瘤,具体可以参考Gavinzheng的提交 考虑魔改dijkstra 首先,每次拿权值最小的来松弛肯定没有问题,只是怎么 ... 
- map与unordered_map区别及使用
			需要引入的头文件不同map: #include <map>unordered_map: #include <unordered_map> 内部实现机理不同map: map内部实 ... 
- pcm-pcie 解析
			简介 pcm 全称为 Performance Counter Monitor,该项目是针对 intel 平台处理器的资源利用率进行监控的工具.在现代 Intel 处理器已经提供了监视处理器内部性能事件 ... 
- URI和URL的区别(转)
			转载:http://www.cnblogs.com/gaojing/archive/2012/02/04/2413626.html 这两天在写代码的时候,由于涉及到资源的位置,因此,需要在Java B ... 
- 零基础学习java------day5------do....while循环、嵌套、方法(函数)
			1 do...while循环 格式 初始化语句; do { 循环体语句; 控制条件语句; }while(判断条件语句); 流程: 先执行初始化语句 再执行循环体语句 再执行条件控制语句 再做条件的判 ... 
