Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created January 16, 2015 20:06
Show Gist options
  • Save theoremoon/7658a89f53a0c0738c43 to your computer and use it in GitHub Desktop.
Save theoremoon/7658a89f53a0c0738c43 to your computer and use it in GitHub Desktop.
/*
* AOJ 1187
* Wrong Answer
*/
#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<long, int> pr; // first: pts, second: team number;
int penalty[50][10]; // [team][problem number]
pr pts[50];
priority_queue<int> list;
int m, t, p, r;
int printout(int n, long pre) {
if (n < t && pre == pts[n].first) {
list.push(pts[n].second);
return printout(n+1, pre);
} else {
int size = list.size();
if (size == 0) return 1;
while (true) {
cout << list.top();
list.pop();
if (list.empty()) break;
cout << "=";
}
return size;
}
cout << "ERR" << endl;
return 0;
}
int main() {
while (true) {
cin >> m >> t >> p >> r;
if (m == 0 && t == 0 && p == 0 && r == 0) break;
for (int i = 0; i < t; ++i) {
pts[i].second = i+1;
pts[i].first = 0;
for (int j = 0; j < p; ++j)
penalty[i][j] = 0;
}
for (int i = 0; i < r; ++i) {
int a, b, c, d;
cin >> a >> b >> c >> d;
if (d == 0) {
pts[b-1].first += -10000 + a + penalty[b-1][c-1];
} else {
penalty[b-1][c-1] += 20;
}
}
sort(pts, pts + t);
int i = 0;
while (true) {
i += printout(i, pts[i].first);
if (i >= t)
break;
cout << ",";
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment