The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.

Input Specification:

Each input file contains one test case. For each case, the first line contains 3 positive integers, N (≤), the total number of users, K (≤), the total number of problems, and M (≤), the total number of submissions. It is then assumed that the user id's are 5-digit numbers from 00001 to N, and the problem id's are from 1 to K. The next line contains K positive integers p[i] (i=1, ..., K), where p[i]corresponds to the full mark of the i-th problem. Then M lines follow, each gives the information of a submission in the following format:

user_id problem_id partial_score_obtained

where partial_score_obtained is either − if the submission cannot even pass the compiler, or is an integer in the range [0, p[problem_id]]. All the numbers in a line are separated by a space.

Output Specification:

For each test case, you are supposed to output the ranklist in the following format:

rank user_id total_score s[1] ... s[K]

where rank is calculated according to the total_score, and all the users with the same total_scoreobtain the same rank; and s[i] is the partial score obtained for the i-th problem. If a user has never submitted a solution for a problem, then "-" must be printed at the corresponding position. If a user has submitted several solutions to solve one problem, then the highest score will be counted.

The ranklist must be printed in non-decreasing order of the ranks. For those who have the same rank, users must be sorted in nonincreasing order according to the number of perfectly solved problems. And if there is still a tie, then they must be printed in increasing order of their id's. For those who has never submitted any solution that can pass the compiler, or has never submitted any solution, they must NOT be shown on the ranklist. It is guaranteed that at least one user can be shown on the ranklist.

Sample Input:

7 4 20
20 25 25 30
00002 2 12
00007 4 17
00005 1 19
00007 2 25
00005 1 20
00002 2 2
00005 1 15
00001 1 18
00004 3 25
00002 2 25
00005 3 22
00006 4 -1
00001 2 18
00002 1 20
00004 1 15
00002 4 18
00001 3 4
00001 4 2
00005 2 -1
00004 2 0

Sample Output:

1 00002 63 20 25 - 18
2 00005 42 20 0 22 -
2 00007 42 - 25 - 17
2 00001 42 18 18 4 2
5 00004 40 15 0 25 -
 #include<bits/stdc++.h>
using namespace std;
struct Result{
int id=,score[]={-,-,-,-,-,-},rank=,num=,totalScore=;//id、每题分数、排名、满分的题目个数、总分
bool flag=false;//标志是否有通过编译的代码,即是否要进行输出
};
bool cmp(const Result&r1,const Result&r2){//比较函数
if(r1.totalScore!=r2.totalScore)
return r1.totalScore>r2.totalScore;
else if(r1.num!=r2.num)
return r1.num>r2.num;
else
return r1.id<r2.id;
}
Result m[(int)(1e5+)];//Result的数组
int main(){
int N,K,M;
scanf("%d%d%d",&N,&K,&M);
int P[K+];//存储每题的满分
for(int i=;i<=K;++i)
scanf("%d",&P[i]);
while(M--){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
m[a].id=a;
if(c>-)//有通过编译的代码
m[a].flag=true;//置flag为true
else if(c==-)//不能通过编译
c=;//置得分为0
m[a].score[b]=max(m[a].score[b],c);//更新该题得分为最高分
}
for(int i=;i<=N;++i)//遍历数组result
if(m[i].flag)//需要进行输出
for(int j=;j<=K;++j){//遍历考试的所有题目
if(m[i].score[j]==P[j])//有拿满分的题目
++m[i].num;//递增满分题目数
m[i].totalScore+=m[i].score[j]<?:m[i].score[j];//更新总分
}
sort(m+,m+N+,cmp);//排序
for(int i=;i<=N;++i)//得出排名
m[i].rank=m[i].totalScore!=m[i-].totalScore?i:m[i-].rank;
for(int i=;i<=N;++i)//遍历数组result
if(m[i].flag){//输出
printf("%d %05d %d",m[i].rank,m[i].id,m[i].totalScore);
for(int j=;j<=K;++j)
if(m[i].score[j]<)//该题没有通过编译或没有提交
printf(" -");//输出-
else
printf(" %d",m[i].score[j]);
printf("\n");
}
return ;
}

PAT甲级——A1075 PAT Judge的更多相关文章

  1. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  2. PAT甲级1075 PAT Judge

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032 题意: 有m次OJ提交记录,总共有k道 ...

  3. PAT 甲级 1141 PAT Ranking of Institutions

    https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...

  4. PAT 甲级 1025 PAT Ranking

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  5. PAT 甲级 1025.PAT Ranking C++/Java

      Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...

  6. PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)

    题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...

  7. PAT甲级——A1025 PAT Ranking

    Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...

  8. PAT甲级——1025 PAT Ranking

    1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...

  9. A1075 PAT Judge (25)(25 分)

    A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...

随机推荐

  1. Jmeter----请求依赖之边界值提取器

    填写左边界和右边界 引用变量名就是要存储的变量名词

  2. java排序及泛型

    一.用泛型实现快排,可以传入不通类型进行排序,比如String数组,Integer数组. /** * 快速排序 * * @author chx * */ public class QuickSort ...

  3. ASCII part of UTF8

    UTF8 所以,本着节约的精神,又出现了把Unicode编码转化为“可变长编码”的UTF-8编码. UTF-8编码把一个Unicode字符根据不同的数字大小编码成1-6个字节,常用的英文字母被编码成1 ...

  4. excel 导数据

    参考: ="insert tsilverinfo(ss_id,memo,ss_weight,ts_id,ss_type,ModelPosX,ss_stoneW,ss_stoneWU) val ...

  5. Android 开发 框架系列 OkHttp文件上传功能实现(含断点续传)

    前言 此篇博客只是上传功能的记录demo,如果你还不太了解okhttp可以参考我的另一篇博客https://www.cnblogs.com/guanxinjing/p/9708575.html 代码部 ...

  6. bootstrap-----流体布局解析

    流体布局容器 容器的width为auto,只是两边加了15px的padding. 流体布局容器 容器的width为auto,只是两边加了15px的padding. <div class=&quo ...

  7. ForkJoin学习笔记

    1.Fork/Join框架:(分治算法思想) 在必要的情况下,将一个大任务,进行拆分(fork) 成若干个子任务(拆到不能再拆,这里就是指我们制定的拆分的临界值),再将一个个小任务的结果进行join汇 ...

  8. git使用过程中问题

    git提交文件命令顺序 fetch merge add commit pull push 取消已add文件 git reset HEAD 文件名 覆盖本地文件 git checkout 文件名 $ g ...

  9. 从零学React Native之13 持久化存储

    数据持久化就是指应用程序将某些数据存储在手机存储空间中. 借助native存储 这种方式不言而喻,就是把内容传递给native层,通过原生API存储,详见从零学React Native之05混合开发 ...

  10. 为什么程序员都不喜欢使用switch,而是大量的 if……else if ?

    作者:熊爸爸 原文:http://3g.163.com/tech/article/E02RDE6C0511SDDL.html 请用5秒钟的时间查看下面的代码是否存在bug. OK,熟练的程序猿应该已经 ...