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

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

2017 Multi-University Training Contest - Team 1

 1 #pragma comment(linker, "/STACK:102400000,102400000")
 2 #include <bits/stdc++.h>
 3 #include <cstdlib>
 4 #include <cstdio>
 5 #include <iostream>
 6 #include <cstdlib>
 7 #include <cstring>
 8 #include <algorithm>
 9 #include <cmath>
10 #include <cctype>
11 #include <map>
12 #include <set>
13 #include <queue>
14 #include <bitset>
15 #include <string>
16 #include <complex>
17 #define LL long long
18 #define mod 1000000007
19 using namespace std;
20 int n,m;
21 unsigned x,y,z,t,ans[10000007];
22 unsigned rng61(){
23     x^=x<<16;
24     x^=x>>5;
25     x^=x<<1;
26     t=x;
27     x=y;
28     y=z;
29     z=t^x^y;
30     return z;
31 }
32 unsigned  aa[10000007];
33 struct node
34 {
35     int xx;
36     int pos;
37     friend bool operator < (node aaa,node bbb)
38     {
39         return aaa.xx < bbb.xx;
40     }
41 }bb[105];
42 int main()
43 {
44     int t=0;
45     while(scanf("%d %d %u %u %u",&n,&m,&x,&y,&z)!=EOF){
46         for(int i=1; i<=m; i++){
47             scanf("%d",&bb[i].xx);
48             bb[i].pos=i;
49             }
50         for(int i=0; i<n; i++)
51             aa[i]=rng61();
52         sort(bb+1,bb+1+m);
53         bb[m+1].xx=n;
54         for(int i=m;i>=1;i--){
55             nth_element(aa,aa+bb[i].xx,aa+bb[i+1].xx);
56             ans[bb[i].pos]=aa[bb[i].xx];
57         }
58         printf("Case #%d:",++t);
59         for(int i=1;i<=m;i++)
60             printf(" %u",ans[i]);
61         printf("\n");
62     }
63     return 0;
64 }
时间: 2024-10-12 19:49:15

HDU 6040 stl的相关文章

hdu 4941 STL HASH 模拟

http://acm.hdu.edu.cn/showproblem.php?pid=4941 比赛的时候现学的map的find...以前都是用下标做的,但是map用下标查询的话,如果查询的元素不存在,会插入一个新的元素. 贴一个map查找元素找到和找不到的模板 map<pair<int,int>,int>::iterator it=poshash.find(tmppos);//pair<int,int>poshash; int pp; if(it == poshash.

hdu 4941 stl的map&lt;node,int&gt;用法

#include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; typedef struct node{ int x,y; bool operator<(const node &b)const { if(x==b.x) return y<b.y; else return x<b.x; } }node; int main(

hdu 6040 -Hints of sd0061(STL)

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

HDU 6040 Hints of sd0061 思维

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6040 题目大意: 给定数组a, b.要求输出和B长度相同的数组C, C[i]为在A中排名为B[i]的数, 重新排A数组, 使得a[i]必须是a数组中第b[i]+1大的数 解题思路: 首先我们要把数组A求出来.第一想法就是最单纯的将A排个序, 然后输出A[B[i]], 自己还恬不知耻的去交了一发, 要是这都不会T, 还叫啥ACM啊...... 好吧, 我题意理解错了......自己太浮躁了, 检讨一

HDU 6040 Hints of sd0061(nth_element)

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6040 [题目大意] 给出一个随机数生成器,有m个询问,问第bi小的元素是啥 询问中对于bi<bk,bj<bk,有bi+bj<=bk [题解] 我们将所有的询问排序,我们发现倒着处理询问的时候询问区间大小下降非常快, nth_element(start,start+k,end) 可以近似O(n)查询区间中第k小的数字, 并且在处理后保证比第k小小的数字均在其前面(虽然不一定有序), 所以我

hdu 5676(stl 或 深搜)

学习: 字符串的下一个排列,字符串的大小比较.strcmp; stl: #include<bits/stdc++.h> using namespace std; typedef long long ll; char c[50],b[50]; int main(){ int T; scanf("%d",&T); while(T--){ scanf("%s",b); int len = strlen(b); if(len & 1){ len

hdu 4022 STL

题意:给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每个炸弹可以炸横排或竖排的敌人,问你每个炸弹能炸死多少个人. 1 /* 2 HDU 4022 3 G++ 1296ms 4 5 6 */ 7 8 9 #include<stdio.h> 10 #include<iostream> 11 #include<set> 12 #include<map> 13 #include<algorithm> 14 using namespace std; 15

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 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last yea

HDU 4022 stl multiset

orz kss太腻害了. 一.set和multiset基础 set和multiset会根据特定的排序准则,自动将元素进行排序.不同的是后者允许元素重复而前者不允许. 需要包含头文件: #include <set> set和multiset都是定义在std空间里的类模板: 二.set和multiset的功能 和所有关联式容器类似,通常使用平衡二叉树完成.事实上,set和multiset通常以红黑树实作而成. 自动排序的优点是使得搜寻元素时具有良好的性能,具有对数时间复杂度.但是造成的一个缺点就是