zoukankan      html  css  js  c++  java
  • cf493A Vasya and Football

    A. Vasya and Football
    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 firstmoment 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:

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

    Output

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

    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

    这模拟题……也是醉了

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<cmath>
    #include<queue>
    #include<deque>
    #include<set>
    #include<map>
    #include<ctime>
    #define LL long long
    #define inf 0x7ffffff
    #define pa pair<int,int>
    #define pi 3.1415926535897932384626433832795028841971
    using namespace std;
    inline LL read()
    {
        LL x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    struct foul{int x,y;char a[5],b[5];}f[10010];bool operator <(foul a,foul b){return a.x<b.x;}
    char c1[10010],c2[10010];
    int gc[1000];
    int n;
    int main()
    {
    	scanf("%s%s",c1,c2);
    	n=read();
    	for(int i=1;i<=n;i++)
    	{
    		int x,y;
    		char a[5],b[5];
    		f[i].x=read();
    		scanf("%s",f[i].a);
    		f[i].y=read();
    		scanf("%s",f[i].b);
    		if (f[i].a[0]=='a')f[i].y+=100;
    	}
    	sort(f+1,f+n+1);
    	for (int i=1;i<=n;i++)
    	{
    		if (f[i].b[0]=='r')gc[f[i].y]+=2;
    		else gc[f[i].y]++;
    		if (gc[f[i].y]>=2)
    		{
    			if (f[i].y<100)
    			printf("%s %d %d
    ",c1,f[i].y%100,f[i].x);
    			else printf("%s %d %d
    ",c2,f[i].y%100,f[i].x);
    			gc[f[i].y]=-100000;
    		}
    	}
    	return 0;
    	
    }
    
    ——by zhber,转载请注明来源
  • 相关阅读:
    [python]如何理解uiautomator里面的 instance 及使用场景
    [python]如何理解uiautomator里面的 right,left,up,down 及使用场景
    [python] try......except.....finally
    [python]python官方原版编码规范路径
    [python]pip 版本9.0.1升级到10.0.1故障解决办法
    [python]如何理解uiautomator里面的 child, child_by_text, sibling,及使用场景
    [python]关于在python中模块导入问题追加总结
    [Eclipse]如何往eclipse中导入单个python文件,其它类型代码文件也可以参照该方法
    [Eclipse]在重命令文件名时,提示编码格式有问题导致修改失败,需要设置如下几个默认编码为UTF-8
    [MySQL]在安装windows版MySQL时遇到过如下问题Error Nr.1045和Error.Nr.2003,相应解决办法如下
  • 原文地址:https://www.cnblogs.com/zhber/p/4141928.html
Copyright © 2011-2022 走看看