HDU 6040 stl
Hints of sd0061
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2421 Accepted Submission(s): 736
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;
}
0 1 2
2 2 2 2 2
1 1
Case #2: 405510 405510
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define LL long long
#define mod 1000000007
using namespace std;
int n,m;
unsigned x,y,z,t,ans[];
unsigned rng61(){
x^=x<<;
x^=x>>;
x^=x<<;
t=x;
x=y;
y=z;
z=t^x^y;
return z;
}
unsigned aa[];
struct node
{
int xx;
int pos;
friend bool operator < (node aaa,node bbb)
{
return aaa.xx < bbb.xx;
}
}bb[];
int main()
{
int t=;
while(scanf("%d %d %u %u %u",&n,&m,&x,&y,&z)!=EOF){
for(int i=; i<=m; i++){
scanf("%d",&bb[i].xx);
bb[i].pos=i;
}
for(int i=; i<n; i++)
aa[i]=rng61();
sort(bb+,bb++m);
bb[m+].xx=n;
for(int i=m;i>=;i--){
nth_element(aa,aa+bb[i].xx,aa+bb[i+].xx);
ans[bb[i].pos]=aa[bb[i].xx];
}
printf("Case #%d:",++t);
for(int i=;i<=m;i++)
printf(" %u",ans[i]);
printf("\n");
}
return ;
}
最新文章
- 为Tcl编写C的扩展库
- POJ 3261 Milk Patterns 后缀数组求 一个串种 最长可重复子串重复至少k次
- win7+theano with GPU enabled
- OC基础(11)
- 34.pad designer警告
- 【Amazon Linux】免费搭建subversion服务器
- POJ 3414 Pots bfs打印方案
- bbc 大数据
- extjs_04_grid(弹出窗口&;amp;行编辑器 CRUD数据)
- logo集锦
- BZOJ_2157_旅游_树剖+线段树
- IDEA使用Git传放项目
- php多维数组排序
- 【洛谷】2120:[ZJOI2007]仓库建设【斜率优化DP】
- remove()
- VS添加命令行参数main(int argc, char** argv)
- halcon之屌炸天的自标定(1)
- bzoj1031-字符加密
- hibernate 返回自定义对象
- thinkphp中的大字母的意思