Skip to content

Instantly share code, notes, and snippets.

@macrat
Created June 3, 2016 19:10
Show Gist options
  • Save macrat/2eeaa955158ab4e7972645049dc2402c to your computer and use it in GitHub Desktop.
Save macrat/2eeaa955158ab4e7972645049dc2402c to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <iostream>
#include <vector>
class Team {
private:
int resolve, time;
std::vector<int> failures;
public:
int id;
Team(int id, int problems) : id(id) {
for(int i=0; i<problems; i++){
failures.push_back(0);
}
}
void check(int time, int problem, int judge) {
if(!judge){
this->time += time + failures[problem] * 20;
resolve++;
}else{
failures[problem]++;
}
}
bool operator <(const Team& x) const {
if(resolve != x.resolve){
return resolve > x.resolve;
}
if(time != x.time){
return time < x.time;
}
return id > x.id;
}
Team& operator =(const Team& x) {
resolve = x.resolve;
time = x.time;
std::copy(x.failures.begin(), x.failures.end(), std::back_inserter(failures));
id = x.id;
return *this;
}
bool operator ==(const Team& x) const {
return resolve == x.resolve && time == x.time;
}
};
int main() {
while(true){
int time_max, team_num, problem_num, num;
std::cin >> time_max >> team_num >> problem_num >> num;
if(time_max == 0){
break;
}
std::vector<Team> teams;
for(int i=0; i<team_num; i++){
teams.push_back(Team(i+1, problem_num));
}
for(int i=0; i<num; i++){
int time, team, problem, judge;
std::cin >> time >> team >> problem >> judge;
teams[team-1].check(time, problem-1, judge);
}
std::sort(teams.begin(), teams.end());
auto old = *teams.begin();
std::cout << old.id;
for(auto itr=++teams.begin(); itr!=teams.end(); ++itr){
std::cout << (old == *itr ? "=" : ",") << itr->id;
old = *itr;
}
std::cout << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment