#include <map> #include <cstdio> #include <string> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define TEAM_MAX 10005 #define PRO_MAX 105 int team_sum;bool mycmp(string a,string b) { for(int i = 0; i < a.length(); i ++) if(a[i] > 'Z') a[i] -= 32; for(int i = 0; i < b.length(); i ++) if(b[i] > 'Z') b[i] -= 32; return a<b; } struct team_node { int AC; int tol_time; string team_name; int problem[PRO_MAX]; bool operator<(const team_node& T)const { if(T.AC != AC) return AC > T.AC; else if(tol_time != T.tol_time) return tol_time < T.tol_time; else return mycmp(team_name,T.team_name); } }TEAM[TEAM_MAX]; void print() { int rank = 1; if(TEAM[0].AC == 0) return ; printf("%-10d%-30s%-10d%dn",rank,TEAM[0].team_name.c_str(),TEAM[0].AC,TEAM[0].tol_time); for(int i = 1; i < team_sum; i ++) { rank++; if(TEAM[i].AC == 0) return ; if(TEAM[i].AC == TEAM[i-1].AC && TEAM[i].tol_time == TEAM[i-1].tol_time) { printf(" %-30s%-10d%dn",TEAM[i].team_name.c_str(),TEAM[i].AC,TEAM[i].tol_time); } else printf("%-10d%-30s%-10d%dn",rank,TEAM[i].team_name.c_str(),TEAM[i].AC,TEAM[i].tol_time); } } int main() { int N; int time,pro; string team,judge; map<string,int>m; team_sum = 0; cin>>N; while(cin>>time>>team>>pro>>judge) { int id; if(m.find(team) == m.end()) { id = team_sum++; m[team] = id; TEAM[id].AC = TEAM[id].tol_time = 0; TEAM[id].team_name = team; memset(TEAM[id].problem,0,sizeof(TEAM[id].problem)); } else id = (*m.find(team)).second; if(judge == "AC" && TEAM[id].problem[pro] != 1) { TEAM[id].tol_time += time - TEAM[id].problem[pro]; TEAM[id].AC ++; TEAM[id].problem[pro] = 1; } else { if(TEAM[id].problem[pro] == 1) continue; TEAM[id].problem[pro] -= 20; } } sort(TEAM,TEAM+team_sum); print(); return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)