PTA PAT Judge 【模拟题,未完待续】
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 -
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define INF 0x3f3f3f
#define pi acos(-1.0)
#define MAX 100010
#define mod 9973
#define ll long long
/*
n, k, m;
人 题目 提交
*/
const int N =1e5+10;
struct asd{
int name;
int sum;
int a[10];
bool vis[10];
int ff;
};
asd q[N];
bool used[N];
int sco[10];int n,m,k;
bool cmp(asd z,asd x)
{
if(z.sum>x.sum)
return 1;
else if(z.sum==x.sum)
{
int s1,s2;
s1=s2=0;
for(int i=1;i<=k;i++)
{
if(z.a[i]==sco[i])
s1++;
if(x.a[i]==sco[i])
s2++;
}
if(s1>s2)
return 1;
else if(s1==s2)
{
if(z.name<x.name)
return 1;
}
}
return 0;
}
int main()
{
memset(used,0,sizeof(used));
cin>>n>>k>>m;
for(int i=1;i<=k;i++) //分数
scanf("%d",&sco[i]);
for(int i=1;i<=n;i++) //初始化
{
q[i].name=i; //名字
for(int j=1;j<=5;j++)
q[i].a[j]=0; //分数都是0
for(int j=1;j<=5;j++)
q[i].vis[j]=0; //提交
q[i].sum=q[i].ff=0; //sum分数,ff标记提交的那个
}
int mingzi,timu,fenshu;
for(int i=0;i<m;i++)
{
scanf("%d%d%d",&mingzi,&timu,&fenshu);
used[mingzi]=1; //有这个人
if(fenshu!=-1) //交了
{
q[mingzi].ff=1; //就会输出的
q[mingzi].vis[timu]=1; //这道题目会输出;
}
if(fenshu>q[mingzi].a[timu]) //更新分数
{
q[mingzi].a[timu]=fenshu;
}
}
for(int i=1;i<=n;i++)
{
int x=q[i].name;
if(used[x])
{
for(int j=1;j<=k;j++)
{
q[x].sum+=q[x].a[j];
}
}
}
sort(q+1,q+1+n,cmp);
/* for(int i=1;i<=n;i++)
{
int x=q[i].name;
if(used[x])
{
printf("%d %d\n",q[i].name,q[i].sum);
}
}*/
int tep,hh,xx;
hh=xx=1;
for(int i=1;i<=n;i++)
{
int x=q[i].name;
if(used[x]&&q[i].ff)
{
printf("1");
printf(" %05d %d",x,q[i].sum);
for(int j=1;j<=k;j++)
{
if(q[i].vis[j])
printf(" %d",q[i].a[j]);
else
printf(" -");
}
puts("");
xx++;
tep=q[x].sum;
used[x]=0;
break;
}
}
for(int i=1;i<=n;i++)
{
int x=q[i].name;
if(!used[x]||!q[i].ff)
continue;
if(tep>q[i].sum)
{
hh=xx;
tep=q[i].sum;
printf("%d %05d %d",hh,x,tep);
for(int j=1;j<=k;j++)
{
if(q[i].vis[j])
printf(" %d",q[i].a[j]);
else
printf(" -");
}
puts("");
}
else if(tep==q[i].sum)
{
printf("%d %05d %d",hh,x,tep);
for(int j=1;j<=k;j++)
{
if(q[i].vis[j])
printf(" %d",q[i].a[j]);
else
printf(" -");
}
puts("");
xx++;
}
}
return 0;
}
/*
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
*/
PTA PAT Judge 【模拟题,未完待续】的更多相关文章
- PAT A1098 Insertion or Heap Sort (25 分)——堆排序和插入排序,未完待续。。
According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and gr ...
- Go web编程学习笔记——未完待续
1. 1).GOPATH设置 先设置自己的GOPATH,可以在本机中运行$PATH进行查看: userdeMacBook-Pro:~ user$ $GOPATH -bash: /Users/user/ ...
- 关于DOM的一些总结(未完待续......)
DOM 实例1:购物车实例(数量,小计和总计的变化) 这里主要是如何获取页面元素的节点: document.getElementById("...") cocument.query ...
- 布隆过滤器(Bloom Filter) 未完待续
布隆过滤器雏形 未完待续..... 计算错误率 现在有一个空额布隆过滤器, 过滤器里的bit array的大小是m. 咱来插入一个元素. 这次插入过程中的第一个hash函数会算出一个位置, 然后把这个 ...
- 从Socket入门到BIO,PIO,NIO,multiplexing,AIO(未完待续)
Socket入门 最简单的Server端读取Client端内容的demo public class Server { public static void main(String [] args) t ...
- 堆学习笔记(未完待续)(洛谷p1090合并果子)
上次讲了堆,别人都说极其简单,我却没学过,今天又听dalao们讲图论,最短路又用堆优化,问懂了没,底下全说懂了,我???,感觉全世界都会了堆,就我不会,于是我决定补一补: ——————来自百度百科 所 ...
- javascript有用小功能总结(未完待续)
1)javascript让页面标题滚动效果 代码如下: <title>您好,欢迎访问我的博客</title> <script type="text/javasc ...
- ASP.NET MVC 系列随笔汇总[未完待续……]
ASP.NET MVC 系列随笔汇总[未完待续……] 为了方便大家浏览所以整理一下,有的系列篇幅中不是很全面以后会慢慢的补全的. 学前篇之: ASP.NET MVC学前篇之扩展方法.链式编程 ASP. ...
- 我的SQL总结---未完待续
我的SQL总结---未完待续 版权声明:本文为博主原创文章,未经博主允许不得转载. 总结: 主要的SQL 语句: 数据操作(select, insert, delete, update) 访问控制(g ...
- virtualbox搭建ubuntu server nginx+mysql+tomcat web服务器1 (未完待续)
virtualbox搭建ubuntu server nginx+mysql+tomcat web服务器1 (未完待续) 第一次接触到 linux,不知道linux的确很强大,然后用virtualbox ...
随机推荐
- linux nc,nmap,telnet ,natstat命令
说明 在服务器运维中 通常需要知道 机器端口状态 是否开启 是否被防火墙拦截等.今天我们介绍这三个命令 用来检测端口. nc 命令 / TCP # 安装 yum install -y nc nc 命令 ...
- Json——使用Json jar包实现Json字符串与Java对象或集合之间的互相转换
总结一下利用Json相关jar包实现Java对象和集合与Json字符串之间的互相转换: 1.创建的User类: package com.ghj.packageofdomain; public clas ...
- Indri和Terrier搜索引擎的使用
介绍 Indri和Terrier都是开源的搜索引擎,当中Indri作为Lemur项目的一个重要部分,具有强大的查询接口,易建索引,可扩展,高效率等长处.能够在SourceForge Lemur Pro ...
- Intel Active Management Technology
http://en.wikipedia.org/wiki/Intel_Active_Management_Technology Intel Active Management Technology F ...
- Hibernate - DetachedCriteria 的完整用法(转)
现在对 Hibernate的Criteria 的用法进行总结: Hibernate 设计了 CriteriaSpecification 作为 Criteria 的父接口,下面提供了 Crite ...
- CSS属性中Display与Visibility的不同
大多数人很容易将CSS属性display和visibility混淆,它们看似没有什么不同,其实它们的差别却是很大的.visibility属性用来确定元素是显示还是隐藏,这用visibility=&qu ...
- openssl 再爆惊天漏洞及紧急修复指南
openssl 又摊上大事了,2014年6月5日,SSL/TLS Man-in-the-Middle Vulnerability 该漏洞使得攻击者能够拦截恶意中间节点加密和解密数据.同一时候强迫使用弱 ...
- 写入文本文件时“\n”不是回车换行而是个方块“■”的解决方法
用“\n”写入文本文件时,打开文本文件显示的为什么不是回车换行而是个黑方块“■”,但用file()读取时还是认为是一行一行的? 首先在WINDOWS里回车换行是"\r\n"; 而L ...
- SpringMVC实战(注解)
1.前言 前面几篇介绍了SpringMVC中的控制器以及视图之间的映射方式,这篇来解说一下SpringMVC中的注解,通过注解能够非常方便的訪问到控制器中的某个方法. 2.配置文件配置 2.1 注解驱 ...
- Android开发环境搭建时遇到问题的解决方法
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/linux_loajie/article/details/33823637 Android开发环境搭建 ...