The ranklist of PAT is generated from the status list, which shows the scores of the submittions. 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, NNN (≤104\le 10^4≤10

​4

​​), the total number of users, KKK (≤5\le 5≤5), the total number of problems, and MMM (≤105\le 10^5≤10

​5

​​), the total number of submittions. It is then assumed that the user id’s are 5-digit numbers from 00001 to NNN, and the problem id’s are from 1 to KKK. The next line contains KKK positive integers p[i] (i=1, …, KKK), where p[i] corresponds to the full mark of the i-th problem. Then MMM lines follow, each gives the information of a submittion in the following format:

user_id problem_id partial_score_obtained

where partial_score_obtained is either −1-1−1 if the submittion 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_score obtain 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 -

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <algorithm>
  6. #include <math.h>
  7. #include <queue>
  8. #include <stack>
  9. #include <map>
  10. using namespace std;
  11. #define INF 0x3f3f3f
  12. #define pi acos(-1.0)
  13. #define MAX 100010
  14. #define mod 9973
  15. #define ll long long
  16. /*
  17. n, k, m;
  18. 人 题目 提交
  19. */
  20. const int N =1e5+10;
  21. struct asd{
  22. int name;
  23. int sum;
  24. int a[10];
  25. bool vis[10];
  26. int ff;
  27. };
  28. asd q[N];
  29. bool used[N];
  30. int sco[10];int n,m,k;
  31. bool cmp(asd z,asd x)
  32. {
  33. if(z.sum>x.sum)
  34. return 1;
  35. else if(z.sum==x.sum)
  36. {
  37. int s1,s2;
  38. s1=s2=0;
  39. for(int i=1;i<=k;i++)
  40. {
  41. if(z.a[i]==sco[i])
  42. s1++;
  43. if(x.a[i]==sco[i])
  44. s2++;
  45. }
  46. if(s1>s2)
  47. return 1;
  48. else if(s1==s2)
  49. {
  50. if(z.name<x.name)
  51. return 1;
  52. }
  53. }
  54. return 0;
  55. }
  56. int main()
  57. {
  58. memset(used,0,sizeof(used));
  59. cin>>n>>k>>m;
  60. for(int i=1;i<=k;i++) //分数
  61. scanf("%d",&sco[i]);
  62. for(int i=1;i<=n;i++) //初始化
  63. {
  64. q[i].name=i; //名字
  65. for(int j=1;j<=5;j++)
  66. q[i].a[j]=0; //分数都是0
  67. for(int j=1;j<=5;j++)
  68. q[i].vis[j]=0; //提交
  69. q[i].sum=q[i].ff=0; //sum分数,ff标记提交的那个
  70. }
  71. int mingzi,timu,fenshu;
  72. for(int i=0;i<m;i++)
  73. {
  74. scanf("%d%d%d",&mingzi,&timu,&fenshu);
  75. used[mingzi]=1; //有这个人
  76. if(fenshu!=-1) //交了
  77. {
  78. q[mingzi].ff=1; //就会输出的
  79. q[mingzi].vis[timu]=1; //这道题目会输出;
  80. }
  81. if(fenshu>q[mingzi].a[timu]) //更新分数
  82. {
  83. q[mingzi].a[timu]=fenshu;
  84. }
  85. }
  86. for(int i=1;i<=n;i++)
  87. {
  88. int x=q[i].name;
  89. if(used[x])
  90. {
  91. for(int j=1;j<=k;j++)
  92. {
  93. q[x].sum+=q[x].a[j];
  94. }
  95. }
  96. }
  97. sort(q+1,q+1+n,cmp);
  98. /* for(int i=1;i<=n;i++)
  99. {
  100. int x=q[i].name;
  101. if(used[x])
  102. {
  103. printf("%d %d\n",q[i].name,q[i].sum);
  104. }
  105. }*/
  106. int tep,hh,xx;
  107. hh=xx=1;
  108. for(int i=1;i<=n;i++)
  109. {
  110. int x=q[i].name;
  111. if(used[x]&&q[i].ff)
  112. {
  113. printf("1");
  114. printf(" %05d %d",x,q[i].sum);
  115. for(int j=1;j<=k;j++)
  116. {
  117. if(q[i].vis[j])
  118. printf(" %d",q[i].a[j]);
  119. else
  120. printf(" -");
  121. }
  122. puts("");
  123. xx++;
  124. tep=q[x].sum;
  125. used[x]=0;
  126. break;
  127. }
  128. }
  129. for(int i=1;i<=n;i++)
  130. {
  131. int x=q[i].name;
  132. if(!used[x]||!q[i].ff)
  133. continue;
  134. if(tep>q[i].sum)
  135. {
  136. hh=xx;
  137. tep=q[i].sum;
  138. printf("%d %05d %d",hh,x,tep);
  139. for(int j=1;j<=k;j++)
  140. {
  141. if(q[i].vis[j])
  142. printf(" %d",q[i].a[j]);
  143. else
  144. printf(" -");
  145. }
  146. puts("");
  147. }
  148. else if(tep==q[i].sum)
  149. {
  150. printf("%d %05d %d",hh,x,tep);
  151. for(int j=1;j<=k;j++)
  152. {
  153. if(q[i].vis[j])
  154. printf(" %d",q[i].a[j]);
  155. else
  156. printf(" -");
  157. }
  158. puts("");
  159. xx++;
  160. }
  161. }
  162. return 0;
  163. }
  164. /*
  165. 7 4 20
  166. 20 25 25 30
  167. 00002 2 12
  168. 00007 4 17
  169. 00005 1 19
  170. 00007 2 25
  171. 00005 1 20
  172. 00002 2 2
  173. 00005 1 15
  174. 00001 1 18
  175. 00004 3 25
  176. 00002 2 25
  177. 00005 3 22
  178. 00006 4 -1
  179. 00001 2 18
  180. 00002 1 20
  181. 00004 1 15
  182. 00002 4 18
  183. 00001 3 4
  184. 00001 4 2
  185. 00005 2 -1
  186. 00004 2 0
  187. */

PTA PAT Judge 【模拟题,未完待续】的更多相关文章

  1. PAT A1098 Insertion or Heap Sort (25 分)——堆排序和插入排序,未完待续。。

    According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and gr ...

  2. Go web编程学习笔记——未完待续

    1. 1).GOPATH设置 先设置自己的GOPATH,可以在本机中运行$PATH进行查看: userdeMacBook-Pro:~ user$ $GOPATH -bash: /Users/user/ ...

  3. 关于DOM的一些总结(未完待续......)

    DOM 实例1:购物车实例(数量,小计和总计的变化) 这里主要是如何获取页面元素的节点: document.getElementById("...") cocument.query ...

  4. 布隆过滤器(Bloom Filter) 未完待续

    布隆过滤器雏形 未完待续..... 计算错误率 现在有一个空额布隆过滤器, 过滤器里的bit array的大小是m. 咱来插入一个元素. 这次插入过程中的第一个hash函数会算出一个位置, 然后把这个 ...

  5. 从Socket入门到BIO,PIO,NIO,multiplexing,AIO(未完待续)

    Socket入门 最简单的Server端读取Client端内容的demo public class Server { public static void main(String [] args) t ...

  6. 堆学习笔记(未完待续)(洛谷p1090合并果子)

    上次讲了堆,别人都说极其简单,我却没学过,今天又听dalao们讲图论,最短路又用堆优化,问懂了没,底下全说懂了,我???,感觉全世界都会了堆,就我不会,于是我决定补一补: ——————来自百度百科 所 ...

  7. javascript有用小功能总结(未完待续)

    1)javascript让页面标题滚动效果 代码如下: <title>您好,欢迎访问我的博客</title> <script type="text/javasc ...

  8. ASP.NET MVC 系列随笔汇总[未完待续……]

    ASP.NET MVC 系列随笔汇总[未完待续……] 为了方便大家浏览所以整理一下,有的系列篇幅中不是很全面以后会慢慢的补全的. 学前篇之: ASP.NET MVC学前篇之扩展方法.链式编程 ASP. ...

  9. 我的SQL总结---未完待续

    我的SQL总结---未完待续 版权声明:本文为博主原创文章,未经博主允许不得转载. 总结: 主要的SQL 语句: 数据操作(select, insert, delete, update) 访问控制(g ...

  10. virtualbox搭建ubuntu server nginx+mysql+tomcat web服务器1 (未完待续)

    virtualbox搭建ubuntu server nginx+mysql+tomcat web服务器1 (未完待续) 第一次接触到 linux,不知道linux的确很强大,然后用virtualbox ...

随机推荐

  1. CSS3绘制灰太狼动画,绝对精彩

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. javaweb 中的过滤器 包装器

    过滤器要做的事情: 请求过滤器:完毕安全检查,又一次格式化请求首部或体.建立请求审计或日志 响应过滤器:     压缩响应流,追加或改动响应流创建一个全然不同的响应. 过滤器和servlet三个相似地 ...

  3. window服务器开站点(不通用)

    此文章为记录自己的配置流程,其他人不通用 网站服务器:Windows server 2008 R2 (IIS6.1) + Asp.net 数据库服务器:Windows server 2008 R2 + ...

  4. linux字符设备驱动程序框架(老方法)

    #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #inclu ...

  5. WheelView实现省市区三级联动(数据库实现版本号附带完整SQL及数据)

    近期在实现收货地址功能,用到了省市区三级联动效果,网上找到一般都是xml或json.数据源陈旧改动麻烦.改动了一下使用数据库方式实现了一下 数据源解决.因为数据量比較大通过初始化批量运行SQL的方式不 ...

  6. 一览新的 Android Gradle 构建工具:新的 DSL 结构 和 Gradle 2.5

    译者地址:[翻]一览新的 Android Gradle 构建工具:新的 DSL 结构 和 Gradle 2.5 原文:First Look at New Android Gradle Build To ...

  7. error at ::0 can&#39;t find referenced pointcut pointCutName 错误解决方法

    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: publi ...

  8. HDU 1032.The 3n + 1 problem【注意细节】【预计数据不强】【8月21】

    The 3n + 1 problem Problem Description Problems in Computer Science are often classified as belongin ...

  9. Marlin固件之—:基础入门与測试

    一.Marlin的简介 Marlin固件是一个3D打印的开源固件,3D打印固件有很多,Marlin最为健全和强大,当然相对也会复杂一些.使用Gcode控制爱.Gcode是数控机床等工控控制使用范围较广 ...

  10. 在DataGridView控件中实现冻结列分界线

    我们在使用Office Excel的时候,有很多时候需要冻结行或者列.这时,Excel会在冻结的行列和非冻结的区域之间绘制上一条明显的黑线.如下图: (图1) WinForm下的DataGridVie ...