HDU 6040 Hints of sd0061 —— 2017 Multi-University Training 1
Hints of sd0061
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2297 Accepted Submission(s): 687
There are n noobs in the team, the i-th of which has a rating ai. sd0061 prepares one hint for each contest. The hint for the j-th contest is a number bj, which means that the noob with the (bj+1)-th lowest rating is ordained by sd0061 for the j-th contest.
The coach asks constroy to make a list of contestants. constroy looks into these hints and finds out: bi+bj≤bk is satisfied if bi≠bj, bi<bk and bj<bk.
Now, you are in charge of making the list for constroy.
For each test case:
The first line contains five integers n,m,A,B,C. (1≤n≤107,1≤m≤100)
The second line contains m integers, the i-th of which is the number bi of the i-th hint. (0≤bi<n)
The n noobs' ratings are obtained by calling following function n times, the i-th result of which is ai.
unsigned x = A, y = B, z = C;
unsigned rng61() {
unsigned t;
x ^= x << 16;
x ^= x >> 5;
x ^= x << 1;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1e7+;
unsigned n, m;
unsigned rat[MAXN], b[MAXN],p[MAXN], a[MAXN];
unsigned x,y,z;
unsigned rng61() {
unsigned t;
x ^= x << ;
x ^= x >> ;
x ^= x << ;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
bool cmp(int s, int t)
{
return b[s]<b[t];
}
int main()
{
int k=;
while(~scanf("%d %d %u %u %u", &n, &m, &x, &y, &z))
{
for(int i=;i<m;i++){
p[i]=i;
scanf("%d", b+i);
} for(int i=;i<n;i++)
rat[i]=rng61();
sort(p, p+m,cmp);
b[p[m]=m]=n;
for(int i=m-;i>=;i--){
if(b[p[i]]==b[p[i+]]){
a[p[i]]=a[p[i+]];
//continue;
}
nth_element(rat, rat+b[p[i]], rat+b[p[i+]]);
a[p[i]]=rat[b[p[i]]];
}
printf("Case #%d:", ++k);
for(int i=;i<m;i++)
printf(" %u", a[i]);
printf("\n");
}
}
HDU 6040 Hints of sd0061 —— 2017 Multi-University Training 1的更多相关文章
- HDU 6040 - Hints of sd0061 | 2017 Multi-University Training Contest 1
/* HDU 6040 - Hints of sd0061 [ 第k小数查询,剪枝 ] 题意: 给出随机数列 a[N] (N < 1e7) 询问 b[M] (M < 100) ,对于每个询 ...
- hdu 6040 Hints of sd0061(stl: nth_element(arr,arr+k,arr+n))
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- HDU 6040 Hints of sd0061 nth_element函数
Hints of sd0061 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired ...
- HDU 6040 Hints of sd0061(划分高低位查找)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6040 [题目大意] 给出一个随机数生成器,有m个询问,问第bi小的元素是啥 询问中对于bi< ...
- HDU 6040 Hints of sd0061(nth_element)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6040 [题目大意] 给出一个随机数生成器,有m个询问,问第bi小的元素是啥 询问中对于bi< ...
- HDU 6162 - Ch’s gift | 2017 ZJUT Multi-University Training 9
/* HDU 6162 - Ch’s gift [ LCA,线段树 ] | 2017 ZJUT Multi-University Training 9 题意: N节点的树,Q组询问 每次询问s,t两节 ...
- HDU 6170 - Two strings | 2017 ZJUT Multi-University Training 9
/* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问 ...
- HDU 6040 stl
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- Hints of sd0061(快排思想)
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
随机推荐
- threading.get_ident()
https://docs.python.org/3/library/threading.html Return the 'thread identifier' of the current threa ...
- MySQL case when then else end用法
链接:https://blog.csdn.net/konglongaa/article/details/80250253 case具有两种格式,简单case函数和case搜索函数. 1.简单case函 ...
- sql查询XML
--查询Extra里节点UName值等于“黄”的所有信息 select * from t_UserPayLog where Extra.exist('//UName[.="黄"]' ...
- MySQL-创建测试数据
简单的方法(每次增加一倍): insert into tb_user(f_id, f_username) select rand(), f_username from tb_user
- CentOS修改网络设置,不容易啊,终于可以在virtualbox里上网了
CentOS 修改网关 修改对应网卡的网关的配置文件[root@centos]# vi /etc/sysconfig/network修改以下内容NETWORKING=yes(表示系统是否使用网络,一般 ...
- GitBook "How to be a programmer"
网址:https://www.gitbook.com/book/braydie/how-to-be-a-programmer/ 最近看了这本 GitBook,主要讲程序员应该掌握的技能和注意的问题,分 ...
- 洛谷P5018 对称二叉树——hash
给一手链接 https://www.luogu.com.cn/problem/P5018 这道题其实就是用hash水过去的,我们维护两个hash 一个是先左子树后右子树的h1 一个是先右子树后左子树的 ...
- 《JAVA设计模式》之备忘录模式(Memento)
在阎宏博士的<JAVA与模式>一书中开头是这样描述备忘录(Memento)模式的: 备忘录模式又叫做快照模式(Snapshot Pattern)或Token模式,是对象的行为模式. 备忘录 ...
- PHP_CodeIgniter 细节
下载压缩包解压之后, 可以在 application/config/config.php 中修改配置信息,包括编码,目录地址 web目录默认是system,后台目录默认是Application, 可以 ...
- C++中的布尔类型和引用
1,C++ 中的布尔类型: 1,C++ 在 C 语言的基础类型系统之上增加了 bool: 1,C 语言中,没有 bool 类型存在,往往都是用整型代替 bool 类型,常用 0 表示假,用 1 表示真 ...