Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Last active August 29, 2015 14:03
Show Gist options
  • Save cocodrips/70356c0e6602603d2e9d to your computer and use it in GitHub Desktop.
Save cocodrips/70356c0e6602603d2e9d to your computer and use it in GitHub Desktop.
ICPC2013予選 B問題
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
int main(int argc, const char * argv[]){
while(1){
int Time, Team, Problem, Raw;
cin >> Time >> Team >> Problem >> Raw;
if (Time == 0 && Team == 0 && Problem == 0 && Raw == 0) break;
int score[Team][2];
int penalty[Team][Problem];
for (int t = 0; t < Team; ++t){
memset(score[t], 0, sizeof(score[t]));
memset(penalty[t], 0, sizeof(penalty[t]));
}
for (int i = 0; i < Raw; ++i){
int min, team, prob, judge;
cin >> min >> team >> prob >> judge;
team -= 1;
if (judge == 0){
score[team][0] ++;
score[team][1] += min + penalty[team][prob];
} else {
penalty[team][prob] += 20;
}
}
vector<tuple<int, int, int> > result;
for (int t = 0; t < Team; ++t){
result.push_back(make_tuple(score[t][0], -score[t][1], t+1));
}
sort(result.begin(), result.end());
for (int r = Team - 1; r >= 0; r--){
cout << get<2>(result[r]);
if (r > 0){
if ( get<0>(result[r]) == get<0>(result[r-1]) && get<1>(result[r]) == get<1>(result[r-1]) ){
cout << "=";
} else {
cout << ",";
}
}
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment