Content

有两个球队在踢足球,现在给出一些足球运动员被黄牌或红牌警告的时间,求每个队员第一次被红牌警告的时间。

注意:根据足球比赛规则,两张黄牌自动换成一张红牌

数据范围:比赛时间 \(90\) 分钟,足球员号码 \(\leqslant 99\)。

Solution

这道题目就是一个很纯粹的模拟。主要注意以下几点:

  1. 两个球队当中也许有相同号码的球员。比如说近现代的 \(10\) 号球员有很多,比如说齐达内和梅西等。
  2. 球员被红牌下场了,但后面还有可能会录入关于该球员的警告信息,此时应该忽略它。

考虑完这些,模拟就简单多了。

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 题解的更多相关文章

  1. cf493A Vasya and Football

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟

    A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has starte ...

  3. 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 ...

  4. A. Vasya and Football

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. 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 ...

  6. codeforces 493A. Vasya and Football 解题报告

    题目链接:http://codeforces.com/contest/493/problem/A 题目意思:给出两个字符串,分别代表 home 和 away.然后有 t 个player,每个playe ...

  7. Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)

    简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...

  8. CF1082A Vasya and Book 题解

    Content 给定 \(T\) 组数据,每组数据给出四个整数 \(n,x,y,d\).小 V 有一本 \(n\) 页的书,每次可以恰好翻 \(d\) 页,求从第 \(x\) 页恰好翻到第 \(y\) ...

  9. CF1036D Vasya and Arrays 题解

    Content 给定两个长度分别为 \(n\) 和 \(m\) 的数列 \(A,B\).你需要将两个数列都恰好分成 \(k\) 份,使得两个数列中第 \(i(i\in[1,k])\) 份的元素和对应相 ...

随机推荐

  1. SSM整合小项目

    1.文件目录结构 2.MyBatis配置 创建数据库环境 CREATE DATABASE `ssmbuild`; USE `ssmbuild`; DROP TABLE IF EXISTS `books ...

  2. No 'Access-Control-Allow-Origin' header: 跨域问题踩坑记录

    前言 前两周在服务器上部署一个系统时,遇到了跨域问题,这也不是第一次遇到跨域问题了,本来以为解决起来会很顺利,没想到解决过程中遇到了很多坑,所以觉得有必要写一篇博客记录一下这个坑. 问题产生原因 本来 ...

  3. c++基础知识02

    1.前置与后置区别 #include<iostream> using namespace std; int main() { //前置和后置区别 //前置递增或递减 先让变量加减1 然后进 ...

  4. Java培训机构如何选择才能避免被骗?

    近年来,随着IT行业的快速崛起,各类互联网人才供不应求,而Java工程师作为目前最为火爆的岗位之一,更是以高薪+高新技术的标签受到了人们的广泛关注.许多年轻人也看到了这个行业的发展前景,决定报名培训机 ...

  5. uniapp中mqtt的基本使用

    参考文档: [1] https://www.hivemq.com/blog/mqtt-client-library-mqtt-js/ [2] https://www.tabnine.com/code/ ...

  6. python3使用concurrent执行多进程任务

    技术背景 随着计算机技术的发展,诸如GPU和超算平台等越来越发达,这些技术的本质其实并没有带来算法上的革新,之所以能够提升计算的速度和规模,很大程度上是因为分布式和并行计算的优势.这里我们介绍一个简单 ...

  7. CF1554E You

    考虑到删点操作的实质是指认边的方向. 由于这是一棵树,所以有很好的性质. 我们完全可以以此从树叶开始,往上拓扑进行,按照对某个数的取膜的大小来进行操作. 由此可知,除了 \(1\) 以外,任意 \(2 ...

  8. Codeforces 1175G - Yet Another Partiton Problem(李超线段树)

    Codeforces 题面传送门 & 洛谷题面传送门 这是一道李超线段树的毒瘤题. 首先我们可以想到一个非常 trivial 的 DP:\(dp_{i,j}\)​ 表示前 \(i\)​ 个数划 ...

  9. 08 eclipse配置JDK

    eclipse配置JDK1.8 一.打开eclipse:Window>>Preferences: 二.搜索:"jdk",并点击右侧的"Add": 三 ...

  10. 使用dumi生成react组件库文档并发布到github pages

    周末两天玩了下号称西湖区东半球最牛逼的react文档站点生成工具dumi,顺带结合github pages生成了react-uni-comps文档站, 一套弄下来,感觉真香,现在还只是浅尝,高级的特性 ...