zoukankan      html  css  js  c++  java
  • 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 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.

    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

     题意:两个足球队进行比赛 给你n个黄红牌,两张黄牌=一张红牌=罚下场。问你随着时间递增,出现罚下的情况

    题解

            不要重复输出罚下相同一个人的情况就是了,暴力

    ///meek
    #include<bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    #define mem(a) memset(a,0,sizeof(a))
    #define pb push_back
    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;
    }
    //****************************************
    const int N=8005;
    #define mod 10000007
    #define inf 10000007
    #define maxn 10000
    char h[50],a[50],ch[22],ch2[22];
    
    map<string,string> mp;
    map<string,int>mps;
    int HH[1000];
    int AH[1000];
    int u[100];
    int main() {
        mem(HH),mem(AH);mp.clear();
        scanf("%s%s",h,a);
        int n=read(),t,num;
        for(int i=1;i<=n;i++) {
            scanf("%d%s%d%s",&t,ch,&num,ch2);
            if(ch2[0]=='y') {
                 if(ch[0]=='a') {
                     AH[num]++;
                     if(AH[num]>2) continue;
                     if(AH[num]==2) {
                        cout<<a<<" "<<num<<" "<<t<<endl;
                     }
                 }
                 else {
                    HH[num]++;
                     if(HH[num]>2) continue;
                     if(HH[num]==2) {
                        cout<<h<<" "<<num<<" "<<t<<endl;
                     }
                 }
            }
            else {
                if(ch[0]=='a') {
                    if(AH[num]>=2)continue;
                    AH[num]+=2;
                    cout<<a<<" "<<num<<" "<<t<<endl;
                }
                else {
                    if(HH[num]>=2)continue;
                     HH[num]+=2;
                     cout<<h<<" "<<num<<" "<<t<<endl;
                }
            }
        }
        return 0;
    }
    代码
  • 相关阅读:
    教你用photoshop cs5或者cs6做IPad,背景随意换,gif制作,高清教程,原创
    ASP.NET MVC4 IN ACTION学习笔记第一波
    潜移默化学会C#不常用语法《1》动态类型绑定dynamic
    SubSnoic 框架入门到提高(1)全程记录
    杨洋疯狂C# 刊号:201208 第1期ASPNET验证(一)
    杨洋疯狂C# 刊号:201207 第1期
    ASP.NET MVC4 IN ACTION学习笔记第二波
    JavaScript深入【表达式和运算符(上集)】你能过我8关js运算符的题目吗?
    清新空气我的.net(C#)生涯知识总结 跨CSS,JS,JAVA,AJAX,WPF,WCF,LINQ,ASP.NET,Winform,Sqlserver,Mysql,EF,OOP,开发工具等
    潜移默化学会WPF(Treeview异步加载节点)
  • 原文地址:https://www.cnblogs.com/zxhl/p/4979278.html
Copyright © 2011-2022 走看看