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 ...
随机推荐
- idea在ssm项目中引入本地的jar
在对应的lib下,右键找到add...,即可
- js中不同类型作比较
示例: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <met ...
- Activiti学习笔记7 — ReceiveTask机器自动任务的使用
一. 创建流程规则,如下图 二.发布流程 /** * 2.发布一个流程 */ @Test public void testDeployProcess() { RepositoryService rep ...
- Vagrant安装步骤
Vagrant安装步骤 下载添加box镜像 vagrant box add base 远端的box地址或者本地的box文件名 建立box镜像关联 vagrant box add centos72 va ...
- 2019牛客暑期多校训练营(第八场)D-Distance 定期重构
题目传送门 题意: 在一个三维空间中,给出q次操作,每次操作可以在空间中加上一个固定点,或者询问一个点,对于一个询问操作,输出距离这个点最近的固定点的曼哈顿距离. 思路: 官方题解:先假设所有询问都在 ...
- redis随记
CONFIG REWRITE 将config文件 将服务器当前所使用的配置记录到 redis.conf 文件中.
- mysql出现You can’t specify target table for update in FROM clause
在mysql执行下面语句时报错: You can’t specify target table for update in FROM clause UPDATE edu_grade_hgm_1 ' W ...
- excel导入、下载功能
1.excel导入.下载功能 2.首先,我们是居于maven项目进行开发引入poi,如果不是那就手动下载相应的jar包引入项目就可以了 <!-- poi --> <dependenc ...
- hdu多校第一场 1013(hdu6590)Code 凸包交
题意: 给定一组(x1,x2,y),其中y为1或0,问是否有一组(w1,w2,b),使得上述的每一个(x1,x2,y)都满足x1*w1+x2*w2+b在y=1时大于0,在y=-1时小于0. 题解: 赛 ...
- 谈谈域名DNS的缓存问题
可以从很多地方看到,许多刚开始做站的朋友,对域名设置方面的知识原理一知半解,以至于为了某些测试需要,经常对域名解析大动干戈.今天改个A记录,明天又换个NS.又或者,在迁移域名,迁移网站的时候的时候由于 ...