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. margin 负值问题

    * margin-top 和 margin-left 负值,自身元素向上.向左移动: * margin-right 负值,右侧元素左移,自身元素不受影响: * margin-bottom 负值,下方元 ...

  2. 【转】Java类MemoryUsage查看虚拟机的使用情况

    原文地址:https://www.cnblogs.com/xubiao/p/5465473.html Java类MemoryUsage,通过MemoryUsage可以查看Java 虚拟机的内存池的内存 ...

  3. MyEclipse增强代码补全

    MyElipse的默认代码提示功能隐藏了许多细节,需要开发者手动设置,一起来设置吧,让你的myeclpse更强大. 方法 1 打开MyEclipse 6.0.1,然后“window”→“Prefere ...

  4. 洛谷 P3455 [POI2007]ZAP-Queries (莫比乌斯函数)

    题目链接:P3455 [POI2007]ZAP-Queries 题意 给定 \(a,b,d\),求 \(\sum_{x=1}^{a} \sum_{y=1}^{b}[gcd(x, y) = d]\). ...

  5. Opengl ES Glew库 ----- By YDD的铁皮锅

    前一篇随笔我写了Opengl的窗口创建,这一篇随笔我要写OpenGL glew库的使用.首先需要引入头文件h,库文件Lib和动态链接库DLL, 百度搜索OpenGL glew库找到这个纯英文网站,尽量 ...

  6. VC2008中处理CStatic控件的单击STN_CLICKED消息

    在MFC中,静态文本CStatic控件主要是用来作为标签,即作为注释用的.一般情况下不做消息响应.但是有时特殊情况下会做一些消息响应,比如处理单击事件STN_CLICKED等. 在VC2008下使用M ...

  7. [Java Performance] 线程及同步的性能之线程池/ThreadPoolExecutors/ForkJoinPool

    线程池和ThreadPoolExecutors   虽然在程序中可以直接使用Thread类型来进行线程操作,但是更多的情况是使用线程池,尤其是在Java EE应用服务器中,一般会使用若干个线程池来处理 ...

  8. mac 密码重置

    首先请开机或重新启动系统,在电脑刚启动时,请按下键盘上的 command+S 组合键不动, 接下来会在屏幕上看到一串串的命令字符显示,当进入安全模式以后,会看到 一个 root 开始的命令行输入端口. ...

  9. Android编程之Listener侦听的N种写法及实现原理

    写下这个题目时突然想起鲁迅笔下的孔乙已,茴香豆的几种写法,颇有些咬文嚼字的味道.虽然从事手机编程多年,但一直使用的是C和C++编程,由于安卓早期只支持JAVA开发,所以对于时下如火如荼的安卓系统,我一 ...

  10. Python大小写转换

    大小写转换 name = "xiao ming" name = name.upper() # 转为大写 print(name) name = name.lower() # 转为小写 ...