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. Windows下 wamp下Apache配置虚拟域名

    安装好wamp后  找到 找到  Include conf/extra/httpd-vhosts.conf   去掉前面的#   并保存 修改 DocumentRoot  和  ServerName ...

  2. CompletableFuture提高你并发编程能力

    思考:如果有两个顺序执行耗时的方法,你该怎么做??? 例如: public void doHousework() { //烧水 doWater(); //扫地 doFloor(); } 没错,聪明如我 ...

  3. c# networkcomms 3.0实现模拟登陆总结 转载https://www.cnblogs.com/zuochanzi/p/7039636.html

    最近项目需要做一个客户查询状态系统,当前上位机缺少服务功能,于是找到了networkcomms 开源框架,作为项目使用. 最新版networkcomms 下载地址:https://github.com ...

  4. PHP 代码编写注意事项总结归纳

    1- 编写模块化代码 良好的PHP代码应该是模块化代码.PHP的面向对象的编程功能是一些特别强大的工 具,可以把你的应用程序分解成函数或方法.你应该尽可能多的从你的应用程序的服务器端分开前端的HTML ...

  5. Java + selenium Timeout接口用法介绍

    上一篇介绍了关于如何启动浏览器的方法.这篇文章要介绍一下,上一篇代码中关于等待时间的接口方法,代码如下: driver.manage().timeouts().pageLoadTimeout(5, T ...

  6. css3水平垂直居中(不知道宽高同样适用)

    css水平垂直居中 第一种方法: 在父div里加: display: table-cell; vertical-align: middle; text-align: center; 内部div设置: ...

  7. 力扣算法——141LinkedListCycel【E】

    Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked lis ...

  8. Uva10817_Headmaster's Headache

    大致题意就是: 一个学校招聘人,自带老师m个,n个求职的人,需要讲授s个课程,已经知道了每个人工资,问怎么才能让各科至少有两个老师(自带的必须要) 这题刚看的时候大概知道是要状态转移,可问题是,状态转 ...

  9. oracle查询不显示小数点前的0

    1.问题起源       oracle 数据库字段值为小于1的小数时,使用char类型处理,会丢失小数点前面的0       例如0.35就变成了.35 2.解决办法:用to_char函数格式化数字显 ...

  10. Anjular的ng-repeat

    Anjular的ng-repeat不会循环一个二维集合中的一维集合.举个例子:集合 list=  {1,2,{0,1,2},23,222},small={0,1,2},使用ng-repeat" ...