#include#include using namespace std; static const int MAX_PROBLEM = 9; static const int MAX_TEAM = 100; static const int MAX_CONTEST = 10; typedef struct _problem { int minute; int failed; int submit; int solved; }PROBLEM; typedef struct _team { int order; PROBLEM problem[MAX_PROBLEM]; int solved_count; int solved_minute; }TEAM; typedef struct _contest { TEAM team[MAX_TEAM]; }CONTEST; static CONTEST contest[MAX_CONTEST]; static int g_contest_order = 0; static int g_team_order = 0; static int g_problem_order = 0; static int g_minute = 0; static char g_result = 0; static const int MAX_FAILED_MINUTE = 20; void save_succeeded(int contest_order, int team_order, int problem_order, int minute) { if(contest[contest_order].team[team_order].problem[problem_order].solved > 0) return; contest[contest_order].team[team_order].problem[problem_order].minute = contest[contest_order].team[team_order].problem[problem_order].failed * MAX_FAILED_MINUTE; contest[contest_order].team[team_order].problem[problem_order].minute += minute; contest[contest_order].team[team_order].problem[problem_order].solved++; contest[contest_order].team[team_order].order = team_order; contest[contest_order].team[team_order].solved_minute += contest[contest_order].team[team_order].problem[problem_order].minute; contest[contest_order].team[team_order].solved_count++; } void save_failed(int contest_order, int team_order, int problem_order, int minute) { contest[contest_order].team[team_order].problem[problem_order].minute += minute; contest[contest_order].team[team_order].order = team_order; contest[contest_order].team[team_order].problem[problem_order].failed++; contest[contest_order].team[team_order].problem[problem_order].submit++; } void save_failed_not_count(int contest_order, int team_order, int problem_order, int minute) { contest[contest_order].team[team_order].order = team_order; contest[contest_order].team[team_order].problem[problem_order].submit++; } int is_solved(char result) { switch(result) { case 'C': return 1; case 'I': return 0; default: return -1; } return -1; } void process(int contest_order, int team_order, int problem_order, int minute, char result) { if(0 < is_solved(result)) { save_succeeded(contest_order, team_order, problem_order, minute); } else if(0 == is_solved(result)) { save_failed(contest_order, team_order, problem_order, minute); } else { save_failed_not_count(contest_order, team_order, problem_order, minute); } } int func_compare(const void *a, const void *b) { if(0 != ((TEAM*)b)->solved_count - ((TEAM*)a)->solved_count) return ((TEAM*)b)->solved_count - ((TEAM*)a)->solved_count; if(0 != ((TEAM*)b)->solved_minute - ((TEAM*)a)->solved_minute) return ((TEAM*)a)->solved_minute - ((TEAM*)b)->solved_minute; return ((TEAM*)a)->order - ((TEAM*)b)->order; } void output_to_table(TEAM* in) { qsort(in, MAX_TEAM, sizeof(TEAM), func_compare); } void output_table(TEAM* team) { for(int i=0; i 0) submit = 1; if(team[i].problem[j].solved > 0) { solved++; minute += team[i].problem[j].minute; } } if(solved > 0) cout << team[i].order+1 << " " << solved << " " << minute << endl; else if(minute > 0 || submit > 0) cout << team[i].order+1 << " " << 0 << " " << 0 << endl; } } void output(int contest_order) { output_to_table(&contest[contest_order].team[0]); output_table(&contest[contest_order].team[0]); } int main() { memset(&contest, 0x00, MAX_CONTEST*sizeof(CONTEST)); cin >> g_contest_order; int i=0; for(i=0; i > g_team_order >> g_problem_order >> g_minute >> g_result) { process(i, g_team_order-1, g_problem_order-1, g_minute, g_result); } } for(i=0; i
Friday, May 8, 2009
[PC]Contest Scoreboard
WA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment