A. Vasya and Football
来源:互联网 发布:java applet 编辑:程序博客网 时间:2024/05/16 15:03
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 thefirst moment 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).
MCCSKA928 a 3 y62 h 25 y66 h 42 y70 h 25 y77 a 4 y79 a 25 y82 h 42 r89 h 16 y90 a 13 r
MC 25 70MC 42 82CSKA 13 90
#include <iostream>#include <cstring>#include <string>#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;int b[100], c1[110], c2[110], c3[110], c4[110];struct node {int t;char c;int m;char d;}a[100];int cmp(node a, node b) {return a.t < b.t;}int main() {string str1, str2;cin >> str1 >> str2;int n;cin >> n;memset(a, 0, sizeof(a));for (int i = 0; i < n; i++)cin >> a[i].t >> a[i].c >> a[i].m >> a[i].d;sort(a, a + n, cmp);memset(b, 0, sizeof(b));memset(c1, 0, sizeof(c1));memset(c2, 0, sizeof(c2));memset(c3, 0, sizeof(c2));memset(c4, 0, sizeof(c2));int num = 0;//int flag1 = 0, flag2 = 0;for (int i = 0; i < n; i++) {if (a[i].d == 'r' && a[i].c == 'h' && c3[a[i].m] == 0) {b[num++] = i;c3[a[i].m] ++;}else if (a[i].d == 'r' && a[i].c == 'a' && c4[a[i].m] == 0) {b[num++] = i;c4[a[i].m] ++;}else if (a[i].d == 'y' && c1[a[i].m] == 1 && a[i].c == 'h' && c3[a[i].m] == 0) {b[num++] = i;c3[a[i].m] ++;}else if (a[i].d == 'y' && c2[a[i].m] == 1 && a[i].c == 'a' && c4[a[i].m] == 0) {b[num++] = i;c4[a[i].m] ++;}else if (a[i].d == 'y' && a[i].c == 'h')c1[a[i].m] ++;else if (a[i].d == 'y' && a[i].c == 'a')c2[a[i].m] ++;}for (int i = 0; i < num; i++) {if (a[b[i]].c == 'h')cout << str1 << " " << a[b[i]].m << " " << a[b[i]].t << endl;elsecout << str2 << " " << a[b[i]].m << " " << a[b[i]].t << endl;}return 0;}
- A. Vasya and Football
- A Vasya and Football
- A. Vasya and Football
- 493A Vasya and Football
- #281 (div.2) A.Vasya and football
- Codeforces 493A. Vasya and Football 水
- Codeforces 493A Vasya and Football(水)
- codeforce 493A Vasya and Football
- CodeForces-493A.Vasya and Football
- codeforces493 A. Vasya and Football B. Vasya and Wrestling C. Vasya and Basketball
- Codeforces Round #281 (Div. 2) A. Vasya and Football
- Codeforces Round #281 (Div. 2) A - Vasya and Football
- A. Vasya and Socks
- A. Vasya and Socks
- A. Vasya and the Bus
- A. Vasya and the Bus
- A. Vasya and Digital Root
- 460A Vasya and Socks
- Linux字符设备驱动--设备注册
- 2、Java关键字、常量、变量、运算符
- 数据结构—散列表(Hash table,也叫哈希表)
- eclipse或myeclipse中更改所使用的jdk版本的方法,myeclipse中使用jdk1.8
- android多线程下载器
- A. Vasya and Football
- golang判断key是否在map中
- C++实现遍历一个文件夹
- 线程TLAB区域的深入剖析
- android“设置”里的版本号
- toolbar标题居中
- 段寄存器中代码段数据段堆栈段附加段
- android javah 找不到类
- eclipse 快捷键