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. PAT甲级——A1145 HashingAverageSearchTime【25】

    The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...

  2. http常见状态码及其解析

    HTTP状态码常见状态码及其解析 状态码 状态码英文名称 中文描述 100 Continue 继续.客户端应继续其请求 101 Switching Protocols 切换协议.服务器根据客户端的请求 ...

  3. python 模拟双色球输出

    编写Python函数:完成一个双色球彩票的模拟生成过程, 其中前六个为红色球,数字范围1-33,不可重复.最后一个为蓝色球 1-16. import random #red_nums是采集红色球的数字 ...

  4. 注解深入浅出之Retrofit中的注解(三)

    更多andorid高级架构进阶视频免费分享学习请点击:https://space.bilibili.com/474380680 Retrofit中的注解 @Query,@QueryMap,@Field ...

  5. Codeforces 488C Fight the Monster

    Fight the Monster time limit per test             1 second                                   memory ...

  6. Oracle多种表连接方式

    1. 内连接(自然连接) 2. 外连接 (1)左外连接 (左边的表不加限制) (2)右外连接(右边的表不加限制) (3)全外连接(左右两表都不加限制) 3. 自连接(同一张表内的连接) SQL的标准语 ...

  7. LLppdd has a dream!

    LLppdd has a dream Time Limit: 3 s Memory Limit: 256 MB 题目背景 LLppdd经过他充满坎坷的初三后,他的成绩也充满了坎坷. 临近中考了,他希望 ...

  8. 一、hibernate环境搭建

    hibernate环境搭建 下载hibernate hibernate的jar 连接数据库的jar 解压hibernate,解压后目录结构 documentation :对应hibernate开发文档 ...

  9. Android ADB被占用 重启 ADB方法

    前言 ADB 是 android sdk里面的一个工具,这个工具可以用于操作管理 Android 模拟器 和 真实Andriod手机设备.列如 : 执行安装 删除 应用的操作 , 执行 模拟点击屏幕 ...

  10. log库

    https://github.com/orocos-toolchain/log4cpp https://github.com/search?q=glog zlog https://github.com ...