题意:给你n条提交问题的信息,每条信息包括提交的时间,队伍,题目编号,及是否AC。让你根据这n条信息输出每个题目的题号,提交次数,平均提交次数和平均提交时间。
注意:某支队伍AC一题后,再提交该题的信息不统计。只统计已经AC的队伍的信息。
#include<stdio.h>
#include<string.h>
#include<string>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2010;
struct node{
int times[10];
bool ac[10];
int t[10];
}team[N];
void init(){
for(int i=0;i<2005;i++){
for(int j=0;j<10;j++){
team[i].times[j]=0;
team[i].ac[j]=false;
team[i].t[j]=0;
}
}
}
int main(){
//freopen("in.txt","r",stdin);
int n,i,j;
while(scanf("%d",&n)!=EOF){
init();
int id=1;
map<string,int>mp;
int tmpt;
char s[100],timu,tac;
string st;
for(i=0;i<n;i++){
scanf("%d %s %c %c",&tmpt,s,&timu,&tac);
int tmptimu=timu-'A';
st=string(s);
if(!mp[st]){
team[id].times[tmptimu]++;
mp[st]=id;
if(tac=='A'){
team[id].t[tmptimu]+=tmpt;
team[id].ac[tmptimu]=true;
}
id++;
}else{
int tid=mp[st];
if(team[tid].ac[tmptimu]==true){
continue;
}
team[tid].times[tmptimu]++;
if(tac=='A'){
team[tid].ac[tmptimu]=true;
team[tid].t[tmptimu]+=tmpt;
}
}
}
for(i=0;i<9;i++){
int numac=0;
int numt=0;
int numtimes=0;
for(j=1;j<id;j++){
if(team[j].ac[i]){
numac++;
numt+=team[j].t[i];
numtimes+=team[j].times[i];
}
}
printf("%c %d",i+'A',numac);
if(numac==0){
printf("\n");
}else{
printf(" %.2lf %.2lf\n",1.0*numtimes/(1.0*numac),1.0*numt/(1.0*numac));
}
}
}
return 0;
}