codeforce 493A Vasya and Football

原本只想练练手感,但仍然碰到了麻烦,这题最坑的是被红牌罚下的球员居然能在fouls列表中再次出现,呵呵~注意好这点,认真理清题意后即可顺利完成。

#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,p1[100],p2[100];  //wirte down foul
char ht[25],at[25];
int main(int argc, char *argv[]) {
	//freopen("cin.txt","r",stdin);
	while(cin>>ht>>at>>n){
		memset(p1,0,sizeof(p1));
		memset(p2,0,sizeof(p2));
		int i;
		for(i=0;i<n;i++){
			int ti,number;
			char te[2],ca[2];
			scanf("%d%s%d%s",&ti,te,&number,ca);
			if(te[0]=='h'){
  				if(p1[number]>=2)continue;
				if(ca[0]=='y')p1[number]++;
				else p1[number]+=2;
				if(p1[number]>=2)printf("%s %d %d\n",ht,number,ti);
			}
			else {
				 if(p2[number]>=2)continue;
				 if(ca[0]=='y')p2[number]++;
 				 else p2[number]+=2;
				 if(p2[number]>=2)printf("%s %d %d\n",at,number,ti);
			}
		}
	 }
	 return 0;
}


你可能感兴趣的:(codeforce)