#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
struct student{
int id, grade = 0, perfect_solution = 0;
bool valid = false;
bool questions[5];
};
bool comp(student a, student b){
if(a.grade != b.grade)
return a.grade > b.grade;
if(a.perfect_solution != b.perfect_solution)
return a.perfect_solution > b.perfect_solution;
if(a.valid != b.valid)
return a.valid;
return a.id < b.id;
}
int main()
{
int N, K, M;
cin>>N>>K>>M;
int scores[5];
int submittion[10000][5];
memset(submittion, -2, sizeof(int)*50000);
vector<student> students(N);
for(int i = 0; i < K; i++)
cin>>scores[i];
for(int i = 0; i < M; i++){
int st, question, score;
scanf("%d %d %d", &st, &question, &score);
st--;
question--;
submittion[st][question] = max(submittion[st][question], score);
students[st].questions[question] = true;
}
for(int i = 0; i < N; i++){
students[i].id = i;
for (int j = 0; j < K; j++){
if(students[i].questions[j] && submittion[i][j] >= 0)
{
students[i].grade += submittion[i][j];
students[i].valid = true;
}
if(students[i].questions[j] && submittion[i][j] == scores[j])
students[i].perfect_solution ++;
}
}
sort(students.begin(), students.end(), comp);
int current_grade = 0, current_rank = 0, real_rank = 0;
for(auto itr = students.begin(); itr != students.end(); itr++)
{
if (!itr -> valid)
return 0;
real_rank ++;
if(itr -> grade != current_grade){
current_grade = itr -> grade;
current_rank = real_rank;
}
printf("%d %05d %d", current_rank, itr->id + 1, itr->grade);
for(int i = 0; i < K; i++){
if (itr-> questions[i])
printf(" %d", max(submittion[itr->id][i], 0));
else
printf(" -");
}
printf("\n");
}
}
|