首页 > 代码库 > A Vasya and Football

A Vasya and Football

一开始跪了一发,

注意一个坑:题目中好像没有说明不会出现重复红牌、多黄牌的情况;需要进行排除;

本人是这里加了判断: if((t2[0]==‘r‘ || f1[number]==2) && f1[number]<=2)  之后过的。

 

AC Code:

#include <iostream>#include <stdio.h>#include <algorithm>#include <cstring>#include <string.h>#include <math.h>#include <queue>#include <stack>#include <stdlib.h>#include <map>using namespace std;#define LL long long #define sf(a) scanf("%d",&(a));#define N 35char name1[N],name2[N];int f1[10010],f2[10010];int main(){    scanf("%s %s",name1,name2);    int n;    scanf("%d",&n);    while(n--){        char t1[N],t2[N];        int t,number;        scanf("%d %s %d %s",&t,t1,&number,t2);        if(t1[0]==h){            //主场            f1[number]++;            if((t2[0]==r || f1[number]==2) && f1[number]<=2)            {                f1[number] = 3;                printf("%s %d %d\n",name1,number,t);            }        }else{            f2[number]++;            if((t2[0]==r || f2[number]==2) && f2[number]<=2){                f2[number]=3;                printf("%s %d %d\n",name2,number,t);            }        }    }    return 0;}

 

A Vasya and Football