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. SpringCloud升级之路2020.0.x版-44.避免链路信息丢失做的设计(1)

    本系列代码地址:https://github.com/JoJoTec/spring-cloud-parent 我们在这一节首先分析下 Spring Cloud Gateway 一些其他可能丢失链路信息 ...

  2. Mac下source tree 下的安装

    安装时出现了以下错误,解决方法 git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=source ...

  3. Excel-计算年龄、工龄 datedif()

    函数名称:DATEDIF 主要功能:计算返回两个日期参数的差值. 使用格式:=DATEDIF(date1,date2,"y").=DATEDIF(date1,date2," ...

  4. Git五个常见问题及解决方法

    一.删除远程仓库上被忽略的文件 由于种种原因,一些本应该被忽略的文件被我们误操作提交到了远程仓库了.那么我们该怎么删除这些文件呢? 以误提交了.idea目录为例,我们可以通过下面的步骤处理: 1)我们 ...

  5. Shell 输出第五行的内容

    目录 Shell 输出第五行的内容 题目 题解-awk 题解-sed Shell 输出第五行的内容 题目 写一个 bash脚本以输出一个文本文件 nowcoder.txt 中第5行的内容. 示例: 假 ...

  6. CPU如何同时运行多个进程?

    1 # -*- coding: utf-8 -*- 2 import re 3 mem = [x for x in re.split('[\r|\n]', ''' 4 store a 1 5 add ...

  7. 源码分析-Consumer

    消息消费概述 消息消费以组的模式开展,一个消费组内可以包含多个消费者,每一个消费者组可订阅多个主题,消费组之间有集群模式和广播模式两种消费模式. 集群模式,主题下的同一条消息只允许被其中一个消费者消费 ...

  8. 【leetcode】378. Kth Smallest Element in a Sorted Matrix(TOP k 问题)

    Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kt ...

  9. int是几位;short是几位;long是几位 负数怎么表示

    其实可以直接通过stm32的仿真看到结果:(这里是我用keil进行的测试,不知道这种方法是否准确) 从上面看, char是8位  short是4*4=16位  int是8*4=32位  long是8* ...

  10. Oracle中创建DB LINK

    当用户要跨本地数据库,访问另外一个数据库表中的数据时,本地数据库中必须创建了远程数据库的dblink,通过dblink本地数据库可以像访问本地数据库一样访问远程数据库表中的数据.下面讲介绍如何在本地数 ...