PAT甲级——A1075 PAT Judge
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_score
obtain 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的更多相关文章
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT甲级1075 PAT Judge
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032 题意: 有m次OJ提交记录,总共有k道 ...
- PAT 甲级 1141 PAT Ranking of Institutions
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...
- PAT 甲级 1025 PAT Ranking
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- PAT 甲级 1025.PAT Ranking C++/Java
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...
- PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)
题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...
- PAT甲级——A1025 PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...
- PAT甲级——1025 PAT Ranking
1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...
- A1075 PAT Judge (25)(25 分)
A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...
随机推荐
- bias、variance与拟合之间的关系
Error = Bias^2 + Variance+Noise 误差的原因: 1.Bias反映的是模型在样本上的输出与真实值之间的误差,即模型本身的精准度,即算法本身的拟合能力. 2.Variance ...
- css 写一个向右的箭头
经常写移动端页面时会用到向右的箭头,之前都是用图片,突然想到用css应该也能写,于是一搜还确实有 width: 7px; height: 7px; border-top: 2px solid #fff ...
- VisualGDB使用随笔
VisualGDB是目前我遇到的在Windows下开发Linux应用程序最好用的软件,它不仅可以直接在VS环境中编译Linux程序,还可以直接对Linux程序进行调试,极大的方便了Windows程序员 ...
- PHP算法之分割平衡字符串
在一个「平衡字符串」中,'L' 和 'R' 字符的数量是相同的. 给出一个平衡字符串 s,请你将它分割成尽可能多的平衡字符串. 返回可以通过分割得到的平衡字符串的最大数量. 示例 1: 输入:s = ...
- CSIC_716_20191104【流程控制语句】
流程控制语句 if 语法结构 if 逻辑判断为真 : xxxxxx else: xxxxx while 语法结构 (continue.break) while 逻辑判断为真: xxxxxxx con ...
- arc098E Range Minimum Queries
题意:给你一个n个数的数组,每次能够选取连续的长度为K的子序列,取出其中任意一个最小元素. 一共操作Q次.问取出的元素中Max-Min最小是多少? 标程: #include<bits/stdc+ ...
- Java 多线程 - Volatile关键字
作者: dreamcatcher-cx 出处: <http://www.cnblogs.com/chengxiao/> 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明 ...
- yield支持的协程
#_author:来童星#date:2019/12/12def consumer(name): print("--->start...") while True: new_b ...
- thinkphp 模板继承
模板继承是一项更加灵活的模板布局方式,模板继承不同于模板布局,甚至来说,应该在模板布局的上层.模板继承其实并不难理解,就好比类的继承一样,模板也可以定义一个基础模板(或者是布局),并且其中定义相关的区 ...
- iOS中消息的传递机制
本文中,会经常提及接收者[recipient]和发送者[sender].在消息传递机制中具体是什么意思,我们可以通过一个示例来解释:一个table view是发送者,而它的delegate就是接收者. ...