HDU 6040---Hints of sd0061(STL)
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 <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=1e7+;
unsigned x,y,z, A,B,C;
unsigned a[N];
struct Node
{
int x;
int id;
unsigned y;
}tr[];
bool cmp(const Node s1,const Node s2)
{
return s1.x<s2.x;
}
bool cmp2(const Node s1,const Node s2)
{
return s1.id<s2.id;
} unsigned rng61() {
unsigned t;
x ^= x << ;
x ^= x >> ;
x ^= x << ;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
} int main()
{
///cout << "Hello world!" << endl;
int n,m,Case=1;
while(scanf("%d%d%u%u%u",&n,&m,&A,&B,&C)!=EOF)
{
x = A, y = B, z = C;
for(int i=;i<n;i++) a[i]=rng61();
printf("Case #%d:",Case++);
for(int i=;i<=m;i++) scanf("%d",&tr[i].x),tr[i].id=i;
sort(tr+,tr+m+,cmp); int p=n;
for(int i=m;i>=;i--)
{
int x = tr[i].x;
nth_element(a,a+x,a+p);
p=x;
tr[i].y=a[x];
}
sort(tr+,tr+m+,cmp2);
for(int i=;i<=m;i++) printf(" %u",tr[i].y);
puts("");
}
return ;
}
HDU 6040---Hints of sd0061(STL)的更多相关文章
- 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 | 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 nth_element函数
Hints of sd0061 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired ...
- 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 ...
- 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 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 ...
- HDU - 1022 Train Problem I STL 压栈
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- Hibernate入门(一)
一 Hibernate介绍 Hibernate 是一个开源.轻量级的ORM(对象关系映射)工具,该工具简化了数据创建.数据处理和数据访问,它是一种将对象映射到数据库中表的编程技术.ORM工具内部使用J ...
- git 知识点汇总
git commit git commit 命令执行后, git 主要执行了三个操作: 为每一个文件生成一个快照 每一个文件其实是真的数据, 所以 git 会把整个文件内容转成二进制, 然后经过压缩直 ...
- 网页中区分IE各版本
CSS Hack 直接在CSS文件中写CSS Hack是非常直观的区分方法.区分不同IE版本的hack代码为 #content{ background:red; /* 所有浏览器 */ backgro ...
- java递归算法实现 数字人民币大写转换
最近穷死了 ,没钱吃饭ing 写点钱给自己吧!public class Test{ public static String getChar(long a){ int b = (int)a; Map ...
- Linux 中最常用的目录及文件管理命令
一.查看文件的命令 对于一个文本文件,在linux中有多种查看方式来获知文件内容,如直接显示整个文本内容.分页查看内容.或者只查看文件开头或末尾的部分内容.在linux可以用不同的命令来实现. 1. ...
- Kafka 源代码分析之log框架介绍
这里主要介绍log管理,读写相关的类的调用关系的介绍. 在围绕log的实际处理上.有很多层的封装和调用.这里主要介绍一下调用结构和顺序. 首先从LogManager开始. 调用关系简单如下:LogMa ...
- jq-animate实现返回顶部效果
jq-animate实现返回顶部效果: <!doctype html> <html lang="en"> <head> <meta cha ...
- create groups 和 create folder reference
当将文件拖入工程中的时候会出现这个对话框,这个对话框中在Added folders中有两种选择:Create groups 和 Create folder references 这两种的区别是 ...
- 排序算法总结及Java实现
1. 整体介绍 分类 排序大的分类可以分为两种,内排序和外排序.在排序过程中,全部记录存放在内存,则称为内排序,如果排序过程中需要使用外存,则称为外排序.主要需要理解的都是内排序算法: 内排序可以分为 ...
- Ext template 的使用
Ext template 的使用 Ext.define('app.view.MyDataView', { extend: 'Ext.panel.Panel', xtype: 'myDataView', ...