Source:

PAT A1075 PAT Judge (25 分)

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), 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 -

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的更多相关文章

  1. PAT 1075 PAT Judge[比较]

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

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

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

  3. 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 ...

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

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

  5. PAT Judge

    原题连接:https://pta.patest.cn/pta/test/16/exam/4/question/677 题目如下: The ranklist of PAT is generated fr ...

  6. 10-排序5 PAT Judge

    用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...

  7. PAT 1075. PAT Judge (25)

    题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075 此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定 ...

  8. PAT A1075 PAT Judge (25 分)——结构体初始化,排序

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

  9. A1075. PAT Judge

    The ranklist of PAT is generated from the status list, which shows the scores of the submittions. Th ...

随机推荐

  1. docker-compose 搭建 Redis Sentinel 测试环境

    docker-compose 搭建 Redis Sentinel 测试环境 本文介绍如何使用 docker-compose 快速搭建一个 Redis Sentinel 测试环境.其中 Redis 集群 ...

  2. js添加onclick中自定义方法

    最近写一个插件的时候遇到了这么一个问题. 插件的要求是,仅仅通过一行js代码,就需要生成相应的页面,不能改变源文件的代码 生成页面还好说,但是有一个问题就是,生成的页面中是有一个按钮的.按钮也是可以添 ...

  3. 实用maven笔记四-打包&其他

    通过使用maven的生命周期和丰富多样的插件,可以方便的将项目代码编译打包为自己需要的构件. maven默认项目主代码位置src/main/java目录,测试代码位置src/test/java目录.主 ...

  4. VMware新建虚拟机之后的初始化工作

    一.开启网络功能(后面的ifcfg-ens33自身系统不同) vi /etc/sysconfig/network-scripts/ifcfg-ens33 ONBOOT=yes systemctl re ...

  5. python+tushare获取沪深港股通持股明细

    接口:hk_hold 描述:获取沪深港股通持股明细,数据来源港交所. 限量:单次最多提取3800条记录,可循环调取,总量不限制 积分:用户积120积分可调取试用,2000积分可正常使用,单位分钟有流控 ...

  6. mavenFailed to execute goal org.apache.maven.plugins:maven-surefire-plugin解决方法

    在项目上右键==>属性==>java构建路径==>源代码,然后把几个文件夹全部删除,然后再添加文件夹中把它们从新添加,然后再maven intall,部署.

  7. 【转载】github 查找最火项目

    博主感觉这篇文章很有用,很方便所以转载过来学习学习. 原文链接地址https://www.cnblogs.com/poterliu/p/10634568.html 如何在github上查找star最多 ...

  8. GitHub-Hexo-Blog 集成Gitalk评论插件

    在本文)末尾可查看先查看效果: 1. 新建New OAuth App 在github中,Settings / Develpoer settings OAuth Apps / New OAuth App ...

  9. 【Luogu】【关卡2-8】广度优先搜索(2017年10月)

    任务说明:广度优先搜索可以用来找有关“最短步数”的问题.恩,也可以用来“地毯式搜索”.

  10. mysql的事务四个特性以及 事务的四个隔离级别

    一.事务四大属性 分别是原子性.一致性.隔离性.持久性. 1,原子性(Atomicity) 原子性是指事务包含的所有操作要么全部成功,要么全部失败回滚,因此事务的操作如果成功就必须要完全应用到数据库, ...