PAT_A1075#PAT Judge
Source:
Description:
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), wherep[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 thetotal_score
, and all the users with the sametotal_score
obtain the samerank
; ands[i]
is the partial score obtained for thei
-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 -
Keys:
- 模拟题
Code:
/*
Data: 2019-07-14 19:26:17
Problem: PAT_A1075#PAT Judge
AC: 43:25 题目大意:
排名
输入:
第一行给出,考生数N<=1e4(考号1~N),问题数K<=5(题号1~K),提交数M<=1e5
接下来一行,各题分值
接下来M行,user_id,pro_id,score(-1表示未通过编译)
输出:
排序按照,总分,满分数,id(各题均为提交,或均未通过编译,视为无效)
次序,user_id,total_socre,ith_score(未提交‘-’,未通过编译‘0’)
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int M=1e5+,P=;
int p[P],full[M]={},val[M]={},sum[M]={};
struct node
{
int score[P];
}info[M]; bool cmp(const int &a, const int &b)
{
if(sum[a]!=sum[b])
return sum[a]>sum[b];
else if(full[a] != full[b])
return full[a] > full[b];
else
return a < b;
} int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE int n,k,m,id,pt,score;
scanf("%d%d%d", &n,&k,&m);
for(int i=; i<=k; i++)
scanf("%d", &p[i]);
for(int i=; i<=n; i++)
fill(info[i].score,info[i].score+P,-);
for(int i=; i<m; i++)
{
scanf("%d%d%d", &id,&pt,&score);
if(info[id].score[pt] < score)
{
info[id].score[pt]=score;
if(score>=)
val[id]=;
if(score == p[pt])
full[id]++;
} }
vector<int> ans;
for(int i=; i<=n; i++)
if(val[i]==)
{
ans.push_back(i);
for(int j=; j<=k; j++)
if(info[i].score[j]>)
sum[i]+=info[i].score[j];
}
sort(ans.begin(),ans.end(),cmp);
int r=;
for(int i=; i<ans.size(); i++)
{
if(i!= && sum[ans[i-]]!=sum[ans[i]])
r=i+;
printf("%d %05d %d", r, ans[i], sum[ans[i]]);
for(int j=; j<=k; j++)
if(info[ans[i]].score[j]==-)
printf(" -");
else if(info[ans[i]].score[j]==-)
printf("");
else
printf(" %d", info[ans[i]].score[j]);
printf("\n");
} return ;
}
PAT_A1075#PAT Judge的更多相关文章
- PAT 1075 PAT Judge[比较]
1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...
- A1075 PAT Judge (25)(25 分)
A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...
- PTA 10-排序5 PAT Judge (25分)
题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge (25分) The ranklist of PA ...
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT Judge
原题连接:https://pta.patest.cn/pta/test/16/exam/4/question/677 题目如下: The ranklist of PAT is generated fr ...
- 10-排序5 PAT Judge
用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...
- PAT 1075. PAT Judge (25)
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075 此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定 ...
- PAT A1075 PAT Judge (25 分)——结构体初始化,排序
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
- A1075. PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. Th ...
随机推荐
- (12)C++ 继承
1继承语法 class Base { public: void print() { cout << "Base" << endl; } }; class S ...
- JSHOP2
JSHOP2是一个HTN(hierarchy task network)规划器,是SHOP2(simple hierarchy ordered planner )的java实现版本. SHOP2的官网 ...
- 【转】开源框架是如何通过JMX来做监控的(一) - JMX简介和Standard MBean
原文链接:https://www.cnblogs.com/trust-freedom/p/6842332.html#autoid-0-0-0 相信很多做Java开发的同学都使用过JDK自带的 jcon ...
- java遇到的问题
1.java 初始化泛型数组 public static <T> T[] toArray(java.util.List<T> src, Class<T> type) ...
- Git操作思维导图
转自:https://blog.csdn.net/mynameishuangshuai/article/details/51657324
- maven项目中 把依赖的jar包一起打包
1.pom.xml 配置文件: 在pom.xml配置文件中添加 <build> <plugins> <plugin> <artifactId>maven ...
- 13-vim-复制和粘贴-01-复制和粘贴
1.vi中提供有一个被复制文本的缓冲区 复制命令会将选中的文字保存在缓冲区. 删除命令删除的文字会被保存在缓冲区 在需要的位置,使用粘贴命令可以将缓冲区的文字插入到光标所在位置. vi中的文本缓冲区同 ...
- quick'n'dirty poc for CVE-2013-1763 SOCK_DIAG bug in kernel 3.3-3.8
/* * quick'n'dirty poc for CVE-2013-1763 SOCK_DIAG bug in kernel 3.3-3.8 * bug found by Spender * po ...
- HDU 4652 Dice (概率DP)
版权声明:欢迎关注我的博客,本文为博主[炒饭君]原创文章,未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/36685493 D ...
- Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale zh_CN
这个是很早以前的一个bug了,最近开始用idea发现追源码相当方便,于是结合网上的解决方案以及自己的判断追踪一下原因,当然没有深究,只是根据提示一直追而已:先说一下解决方案: <dependen ...