相当于是模拟OJ评测,这里注意最后输出:
1.那些所有提交结果都是-1的(即均未通过编译器的),或者从没有一次提交过的用户,不需要输出。
2.提交结果为-1的题目,最后输出分数是0
3.某个题目从没有提交过的,输出'-'

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <queue>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=+;
int problem[]; struct User{
int id;
int score=;
int problem[]={-,-,-,-,-,-};
int submitted[]={,,,,,}; //标记题目是否有提交,没提交的对应的就要输出'-'
int perfect=; //拿满分的题目个数
int ranks=INF;
int isShow=; //用于标记是否要输出,即用户只要有一题通过编译器,不管是否为0,设置为1.
bool operator<(const User tmp)const{
if(ranks==tmp.ranks){
if(perfect==tmp.perfect){
return id<tmp.id;
}
else{
return perfect>tmp.perfect;
}
}
else{
return ranks<tmp.ranks;
}
}
}user[maxn]; bool cmp1(User a, User b){
return a.score>b.score;
} bool cmp2(User a,User b){
if(a.ranks==b.ranks){
if(a.perfect==b.perfect){
return a.id<b.id;
}
else{
return a.perfect>b.perfect;
}
}
else{
return a.ranks<b.ranks;
}
} int main()
{
int N,K,M;
int id,pid,score;
scanf("%d %d %d",&N,&K,&M);
for(int i=;i<=K;i++){
scanf("%d",&problem[i]);
}
for(int i=;i<M;i++){
scanf("%d %d %d",&id,&pid,&score);
user[id].id=id;
user[id].problem[pid]=max(user[id].problem[pid],score);
user[id].submitted[pid]=;
//if(score==problem[pid])
// user[id].perfect++; //不能这里就统计拿满分的题目个数,因为可能存在多次提交
if(score!=-)
user[id].isShow=;
}
for(int i=;i<=N;i++){
for(int j=;j<=K;j++){
if(user[i].problem[j]!=-)
user[i].score+=user[i].problem[j];
if(user[i].problem[j]==problem[j])
user[i].perfect++;
}
}
sort(user+,user+N+,cmp1); int cnt=;
int lastid=;
user[].ranks=cnt;
user[].score=-;
for(int i=;i<=N;i++){
user[i].ranks=i;
if(i!= && user[i].score==user[i-].score)
user[i].ranks=user[i-].ranks;
}
sort(user+,user+N+,cmp2);
for(int i=;i<=N;i++){
if(user[i].isShow==)
continue;
printf("%d %05d %d",user[i].ranks,user[i].id,user[i].score);
for(int j=;j<=K;j++){
if(user[i].submitted[j]==){
printf(" -");
}
else{
if(user[i].problem[j]!=-)
printf(" %d",user[i].problem[j]);
else
printf("");
}
}
printf("\n");
}
return ;
}

PAT甲题题解-1075. PAT Judge (25)-排序的更多相关文章

  1. PAT甲题题解-1129. Recommendation System (25)-排序

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789819.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  2. PAT甲题题解-1051. Pop Sequence (25)-堆栈

    将1~n压入最多为m元素的栈 给出k个出栈序列,问你是否能够实现. 能输出YES 否则NO 模拟一遍即可,水题. #include <iostream> #include <cstd ...

  3. PAT甲题题解-1059. Prime Factors (25)-素数筛选法

    用素数筛选法即可. 范围long int,其实大小范围和int一样,一开始以为是指long long,想这就麻烦了该怎么弄. 而现在其实就是int的范围,那难度档次就不一样了,瞬间变成水题一枚,因为i ...

  4. PAT甲题题解-1101. Quick Sort (25)-大水题

    快速排序有一个特点,就是在排序过程中,我们会从序列找一个pivot,它前面的都小于它,它后面的都大于它.题目给你n个数的序列,让你找出适合这个序列的pivot有多少个并且输出来. 大水题,正循环和倒着 ...

  5. PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)

    如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...

  6. PAT甲题题解-1130. Infix Expression (25)-中序遍历

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789828.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  7. PAT甲题题解-1016. Phone Bills (25)-模拟、排序

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789229.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  8. PAT甲题题解-1021. Deepest Root (25)-dfs+并查集

    dfs求最大层数并查集求连通个数 #include <iostream> #include <cstdio> #include <algorithm> #inclu ...

  9. PAT甲题题解-1024. Palindromic Number (25)-大数运算

    大数据加法给一个数num和最大迭代数k每次num=num+num的倒序,判断此时的num是否是回文数字,是则输出此时的数字和迭代次数如果k次结束还没找到回文数字,输出此时的数字和k 如果num一开始是 ...

随机推荐

  1. 1.4环境的准备(四)之Pycharm的使用技巧

    返回总目录 目录: 1.快捷键的使用: 2.提示技巧: 3.其他技巧: (一)快捷键的使用: (1)Pycharm自带默认的快捷键 1.Ctrl + C 复制 2.Ctrl + V 粘贴 3.Ctrl ...

  2. 团队-UML

    UML设计 分工 刘双玉 李佳铭 杜宏庆 肖小强 汪志彬 江郑 符天愉 邓弘立 后台数据库 求购模块 浏览检索商品 即时聊天系统 商品管理 管理员系统 后台商品发布收藏系统 登录注册与个人信息系统 U ...

  3. C# ActiveX 网页打包验证自动升级

    原文地址:http://www.cnblogs.com/yilin/p/csharp-activex.html 注意事项:Win10下需要设置兼容模式,F12仿真切换到IE6-8(版本参考——BT90 ...

  4. luogu P2365 任务安排

    嘟嘟嘟 如果常规dp,\(dp[i][j]\)表示前\(i\)个任务分\(j\)组,得到 \[dp[i][j] = min _ {k = 0} ^ {i - 1} (dp[k][j - 1] + (s ...

  5. Apache服务器的安装与配置

    文档:http://httpd.apache.org/docs/2.4/ 指令:http://httpd.apache.org/docs/2.4/mod/core.html 一.配置文件 语法 * 主 ...

  6. leetcode717—1-bit and 2-bit Characters

    We have two special characters. The first character can be represented by one bit 0. The second char ...

  7. PAT B1027 打印沙漏 (20 分)

    本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号:各行符号中心对齐:相邻两 ...

  8. vector,deque,list的区别和使用

    vector: 表示一段连续的内存区域,每个元素被顺序存储在这段内存中,对vector的随机访问效率很高,但对非末尾元素的插入和删除则效率非常低. deque: 也表示N段连续的内存区域组成,但与ve ...

  9. day39

    今日内容: 1.对于表,库,记录的基本操作 2.数据库引擎的了解 3.表的详细 4.数据类型的掌握 1.回顾昨日对于表,库,记录的基本操作 库 增: create database mydb2; 删: ...

  10. Fiddler抓包调试前端脚本代码

    0.写在前面的话 之前看了阮一峰老师关于互联网协议入门的博客,受益匪浅,接着再去体会了下HTTP协议,就想着看实际网络访问中的那些HTTP请求头和响应是什么样的.Chrome的调试工具的Network ...