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

Problem Description
sd0061, the legend of Beihang University ACM-ICPC Team, retired last year leaving a group of noobs. Noobs have no idea how to deal with m coming contests. sd0061 has left a set of hints for them.

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.

 
Input
There are multiple test cases (about 10).

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;
}
 
Output
For each test case, output "Case #x: y1 y2 ⋯ ym" in one line (without quotes), where x indicates the case number starting from 1 and yi (1≤i≤m) denotes the rating of noob for the i-th contest of corresponding case.
 
Sample Input
3 3 1 1 1
0 1 2
2 2 2 2 2
1 1
 
Sample Output
Case #1: 1 1 202755
Case #2: 405510 405510
 
Source
 
 #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 ;
}

最新文章

  1. 为Tcl编写C的扩展库
  2. POJ 3261 Milk Patterns 后缀数组求 一个串种 最长可重复子串重复至少k次
  3. win7+theano with GPU enabled
  4. OC基础(11)
  5. 34.pad designer警告
  6. 【Amazon Linux】免费搭建subversion服务器
  7. POJ 3414 Pots bfs打印方案
  8. bbc 大数据
  9. extjs_04_grid(弹出窗口&amp;amp;行编辑器 CRUD数据)
  10. logo集锦
  11. BZOJ_2157_旅游_树剖+线段树
  12. IDEA使用Git传放项目
  13. php多维数组排序
  14. 【洛谷】2120:[ZJOI2007]仓库建设【斜率优化DP】
  15. remove()
  16. VS添加命令行参数main(int argc, char** argv)
  17. halcon之屌炸天的自标定(1)
  18. bzoj1031-字符加密
  19. hibernate 返回自定义对象
  20. thinkphp中的大字母的意思

热门文章

  1. du命令详解
  2. Python基础_可迭代的/迭代器/生成器
  3. 信息安全系统设计基础_exp1
  4. Bag类课后作业
  5. cnblogs用户体验及建议
  6. 第三周作业(三)WordCount
  7. grunt入门讲解4:如何创建task(任务)
  8. vue之Mutations 理解
  9. 蜗牛慢慢爬 LeetCode 9. Palindrome Number [Difficulty: Easy]
  10. c3p0连接池基本配置mysql和oracle