- 成绩分为以下三种情况:
- 正常提交,得分>=0
- 编译失败,标识为-1,得分0,在输出时为0
- 无提交,在输出时为
-
- 成绩排序规则:
- 按照总成绩降序
- 总成绩相同,按照AC数量降序
- 总成绩和AC数量相同,按照id升序
- 不参与排名的情况:
- 无提交
- 提交结果全部编译失败
题目有一个很隐晦的边界情况:
某个考生所有题目都通过了编译,但是都得了0分
这个学生也是要输出的,因为并没有违背“全场没有提交,或是没有能通过编译的提交”这个情况
他编译通过了,也提交了,只是都得了0分而已
注意排名计算公式:
//sc: 上一名的分数
//rk: 当前排名
if (stu[i].tot < sc) { sc = stu[i].tot; rk = i; }
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 10010;
int n, m, k;
int total_score[10];
struct node {
int id;
int score[10];
int tot;
int perfect;
};
node stu[N];
int cmp(const node &A,const node &B) {
return (A.tot > B.tot) ||
(A.tot == B.tot && A.perfect > B.perfect) ||
(A.tot == B.tot && A.perfect == B.perfect && A.id < B.id);
}
int main()
{
scanf("%d%d%d", &n, &k, &m);
for (int i = 1; i <= n; ++i) {
stu[i].id = i;
stu[i].tot = 0;
stu[i].perfect = 0;
for (int j = 1; j <= k; ++j) stu[i].score[j] = -2;
}
for (int i = 1; i <= k; ++i) scanf("%d",&total_score[i]);
for (int i = 1; i <= m; ++i) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
if (z > stu[x].score[y])
stu[x].score[y] = z;
// -2 never submit
// -1 CE is considered as 0 when outputing
}
for (int i = 1; i <= n; ++i) {
int f = 0;
for (int j = 1; j <= k; ++j)
if (stu[i].score[j] >= 0) {
f = 1;
stu[i].tot += stu[i].score[j];
if (stu[i].score[j] == total_score[j])
stu[i].perfect++;
}
if (!f) stu[i].tot = -1;
//never submit or always CE
}
sort(stu + 1, stu + 1 + n, cmp);
int rk = 1;
int sc = stu[1].tot;
for (int i = 1; i <= n; ++i) {
if (stu[i].tot == -1) break;
if (stu[i].tot < sc) { sc = stu[i].tot; rk = i; }
printf("%d %05d %d", rk, stu[i].id, stu[i].tot);
for (int j = 1; j <= k; ++j)
if (stu[i].score[j] >= 0) printf(" %d", stu[i].score[j]);
else if (stu[i].score[j] == -1) printf(" 0");
else printf(" -");
printf("\n");
}
return 0;
}