简单模拟题。

注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名。

如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分。

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<vector>
  5. #include<map>
  6. #include<stack>
  7. #include<queue>
  8. #include<string>
  9. #include<algorithm>
  10. using namespace std;
  11.  
  12. const int maxn=+;
  13. int n,k,m;
  14. int val[];
  15.  
  16. struct X
  17. {
  18. int Rank;
  19. int num;
  20. int id;
  21. int tot;
  22. int get[];
  23. }s[maxn],ans[maxn];
  24. int sz;
  25.  
  26. bool cmp(const X&a,const X&b)
  27. {
  28. if(a.tot==b.tot&&a.num==b.num) return a.id<b.id;
  29. if(a.tot==b.tot) return a.num>b.num;
  30. return a.tot>b.tot;
  31. }
  32.  
  33. int main()
  34. {
  35. scanf("%d%d%d",&n,&k,&m);
  36. for(int i=;i<=k;i++) scanf("%d",&val[i]);
  37. for(int i=;i<=n;i++)
  38. {
  39. s[i].id=i;
  40. s[i].num=;
  41. s[i].tot=;
  42. for(int j=;j<=k;j++) s[i].get[j]=-;
  43. }
  44.  
  45. for(int i=;i<=m;i++)
  46. {
  47. int id,pro,get;
  48. scanf("%d%d%d",&id,&pro,&get);
  49. s[id].get[pro]=max(s[id].get[pro],get);
  50. }
  51.  
  52. sz=;
  53. for(int i=;i<=n;i++)
  54. {
  55. int fail=;
  56. for(int j=;j<=k;j++)
  57. if(s[i].get[j]>=) fail=;
  58. if(fail==) continue;
  59. ans[sz++]=s[i];
  60. }
  61.  
  62. for(int i=;i<sz;i++)
  63. for(int j=;j<=k;j++)
  64. if(ans[i].get[j]==-) ans[i].get[j]=;
  65.  
  66. for(int i=;i<sz;i++)
  67. {
  68. for(int j=;j<=k;j++)
  69. {
  70. if(ans[i].get[j]==-) continue;
  71. ans[i].tot=ans[i].tot+ans[i].get[j];
  72. if(ans[i].get[j]==val[j]) ans[i].num++;
  73. }
  74. }
  75.  
  76. sort(ans,ans+sz,cmp);
  77.  
  78. ans[].Rank=;
  79. for(int i=;i<sz;i++)
  80. {
  81. if(ans[i].tot==ans[i-].tot)
  82. ans[i].Rank=ans[i-].Rank;
  83. else ans[i].Rank=i+;
  84. }
  85.  
  86. for(int i=;i<sz;i++)
  87. {
  88. printf("%d %05d %d",ans[i].Rank,ans[i].id,ans[i].tot);
  89. for(int j=;j<=k;j++)
  90. {
  91. printf(" ");
  92. if(ans[i].get[j]==-) printf("-");
  93. else printf("%d",ans[i].get[j]);
  94. }
  95. printf("\n");
  96. }
  97.  
  98. return ;
  99. }

PAT (Advanced Level) 1075. PAT Judge (25)的更多相关文章

  1. PTA(Advanced Level)1075.PAT Judge

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

  2. PAT (Advanced Level) 1114. Family Property (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  3. PAT (Advanced Level) 1109. Group Photo (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  4. PAT (Advanced Level) 1105. Spiral Matrix (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...

  5. PAT (Advanced Level) 1101. Quick Sort (25)

    树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...

  6. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  7. PAT (Advanced Level) 1063. Set Similarity (25)

    读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...

  8. PAT (Advanced Level) 1059. Prime Factors (25)

    素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...

  9. PAT (Advanced Level) 1051. Pop Sequence (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. hadoop三个配置文件的参数含义说明core-site.xml,hdfs-site.xml,mapred-site.xml

    配置hadoop,主要是配置core-site.xml,hdfs-site.xml,mapred-site.xml三个配置文件,默认下来,这些配置文件都是空的,所以很难知道这些配置文件有哪些配置可以生 ...

  2. nginx 部署多网站

    1, www 下面加一个文件夹 abc 2,   在default.conf 复制一下 ,abc.conf , 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...

  3. 解决Xcode 9.2系统真机测试时出现 could not find developer disk image问题

    解决Xcode在ipad/iphone 9.2 系统真机测试时出现could not find developer disk image问题 第一种方法:拷贝这个文件(http://download. ...

  4. Oracle10 多行和并

    SELECT fspc, wmsys.wm_concat (jsrzmc) as jsr FROM dxjsrxx GROUP BY fspc select fspc, LISTAGG(jsrzmc, ...

  5. iperf linux版本移植到android (使用工具链方式不是使用Android.mk)

    由于很多程序是用makefile编译linux应用程序的,如果移植到android就要重新写Android.mk,对于不熟悉这个的人来说,特别麻烦,所以这里介绍只修改makefile就能移植到andr ...

  6. Linux 配置tomcat遇见的若干问题

    1.提示catalina.sh缺失 原因:未对bin目录下的.sh文件授权 执行:chmod +x bin/*.sh即可 2.正常启动Tomcat 但是外界无法访问 Linux防火墙原因,进入到 et ...

  7. WinForm 子窗体在父窗体范围内移动,不能出父窗体 摘自于网络

    详细解释:1, 主窗体Form1属性IsMdiContainer设为True,并添加ToolStrip控件, Toolstrip中添加一个按钮toolStripButton1.         2,添 ...

  8. linux fork()函数

    C语言编程创建函数fork() 执行解析 | 浏览:1842 | 更新:2013-04-22 15:12 | 标签:c语言 概述 最近在看进程间的通信,看到了fork()函数,虽然以前用过,这次经过思 ...

  9. Lua 垃圾收集机制

    1. 问题:一款用Lua做的游戏,玩了一段时间后会变卡 因为知道lua是有自动管理内存的机制,所以之前一直没有关注过lua内存的问题.所以今天好好的查看了lua垃圾收集机制.看了一下Lua的Garba ...

  10. “strcmp()” Anyone?

    “strcmp()” Anyone? strcmp() is a library function in C/C++ which compares two strings. It takes two ...