Codeforces Round #281(Div.2) A. Vasya and Football 폭력수 문제
8579 단어 codeforces
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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 first moment of time when he would receive a red card from Vasya.
Input
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:
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.
Output
For each event when a player received his first red card in a chronological order print a string containing the following information:
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).
Sample test(s)
Input
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
Output
MC 25 70
MC 42 82
CSKA 13 90
, , wa
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
int kiss[100];
int kill[100];
int main()
{
memset(kill,0,sizeof(kill));
memset(kiss,0,sizeof(kiss));
string a,b;
cin>>a>>b;
int n;
cin>>n;
while(n--)
{
int q,w;
char m,s;
cin>>q>>m>>w>>s;
if(m=='h')
{
if(s=='y'&&kiss[w]!=-1)
kiss[w]++;
if(s=='r'&&kiss[w]!=-1)
kiss[w]=2;
if(kiss[w]==2)
{
cout<<a<<" "<<w<<" "<<q<<endl;
kiss[w]=-1;
}
}
if(m=='a')
{
if(s=='y'&&kill[w]!=-1)
kill[w]++;
if(s=='r'&&kill[w]!=-1)
kill[w]=2;
if(kill[w]==2)
{
cout<<b<<" "<<w<<" "<<q<<endl;
kill[w]=-1;
}
}
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Codeforces Round #715 Div. 2C The Sports Festival: 구간 DP전형구간 DP의 초전형. 이하, 0-indexed. 입력을 정렬하여 어디서나 시작하고 최적으로 좌우로 계속 유지하면 좋다는 것을 알 수 있습니다. {2000})$의 주문이 된다. 우선, 입력을 소트하여 n개의 요소를 $...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.