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_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的更多相关文章
- 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 ...
随机推荐
- iOS开发系列-定时器强引用问题
概述 iOS开发中常用的定时器NSTimer.CADisplayLink. NSTimer 和 CADisplayLink 基本使用 NSTimer的创建方法有两个scheduledTimerWith ...
- item字母问题
解决方法:复写toString方法 @Override public String toString() { return this.getBookTypeName(); } 将对象的toString ...
- Java 巴什博弈(取石子报数问题)
巴什博弈:有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个.最后取光者得胜. 规律:如果n=m+1,那么由于一次最多只能取m个,所以,无论先取者拿走多少个,后取者都能够一 ...
- SpringBoot 非web项目简单架构
1.截图 2.DemoService package com.github.weiwei02.springcloudtaskdemo; import org.springframework.beans ...
- ETL工具-Kattle:初识kattle
ETL是EXTRACT(抽取).TRANSFORM(转换).LOAD(加载)的简称,实现数据从多个异构数据源加载到数据库或其他目标地址,是数据仓库建设和维护中的重要一环也是工作量较大的一块.当前知道的 ...
- http://www.2cto.com/ 红黑联盟
http://www.2cto.com/ 红黑联盟,一个不错的学习或者开阔眼界的网站,内部由中文书写.比较适合国人.
- CSS表格属性
border-collapse:表格边框线合并,取值:collapse.
- AtCoder ABC 130E Common Subsequence
题目链接:https://atcoder.jp/contests/abc130/tasks/abc130_e 题目大意 给定一个长度为 N 的序列 S 和一个长度为 M 的序列 T,问 S 和 T 中 ...
- 新建mapping
新建索引: PUT logstash-redis-log-2017.12 PUT logstash-redis-log-2017.12/_mapping/redis-log { &quo ...
- Java之RabbitMQ(一)与SpringBoot整合
应用场景:异步处理.应用解耦.流量削峰 参照:https://blog.csdn.net/weixin_38364973/article/details/82834348 开端 RabbitAutoC ...