2017多校联合一/hdu6040Hints of sd0061
来源:互联网 发布:刷码软件 编辑:程序博客网 时间:2024/06/05 13:29
Hints of sd0061
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2311 Accepted Submission(s): 693
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 aren 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.
There are
The coach asks constroy to make a list of contestants. constroy looks into these hints and finds out:
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 integersn,m,A,B,C . (1≤n≤107,1≤m≤100)
The second line containsm integers, the i -th of which is the number bi of the i -th hint. (0≤bi<n)
Then noobs' ratings are obtained by calling following function n times, the i -th result of which is ai .
For each test case:
The first line contains five integers
The second line contains
The
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 10 1 22 2 2 2 21 1
Sample Output
Case #1: 1 1 202755Case #2: 405510 405510
Source
2017 Multi-University Training Contest - Team 1
本题注意一个接近线性的查找函数,STL中的nth_element()方法的使用 通过调用nth_element(start, start+n, end) 方法可以使第n大元素处于第n位置(从0开始,其位置是下标为 n的元素),并且比这个元素小的元素都排在这个元素之前,比这个元素大的元素都排在这个元素之后,但不能保证他们是有序的;
#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <string.h>#include <map>#include <set>#include <queue>#include <deque>#include <list>#include <bitset>#include <stack>#include <stdlib.h>#define lowbit(x) (x&-x)#define e exp(1.0)//ios::sync_with_stdio(false);// auto start = clock();// cout << (clock() - start) / (double)CLOCKS_PER_SEC;typedef long long ll;typedef long long LL;using namespace std;//hdu 6040 m次线性查找第K小// nth_elememnt(A,A+k,A+n)const int maxn=1e7+10;int cas=1;unsigned n,m,x,y,z;unsigned a[maxn],d[105];pair<unsigned,int>s[105];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;}int main(int argc, const char * argv[]){ while(cin>>n>>m>>x>>y>>z) { for(int i=0;i<n;i++) a[i]=rng61(); for(int i=0;i<m;i++) { cin>>s[i].first; s[i].second=i; } sort(s,s+m); s[m].first=n; s[m].second=m; for(int i=m-1;i>=0;i--) { if(s[i].first==s[i+1].first) d[s[i].second]=d[s[i+1].second]; else { nth_element(a,a+s[i].first,a+s[i+1].first); d[s[i].second]=a[s[i].first]; } } cout<<"Case #"<<cas++<<":"; for(int i=0;i<m;i++) cout<<" "<<d[i]; cout<<endl; } return 0;}
阅读全文
0 0
- 2017多校联合一/hdu6040Hints of sd0061
- 2017多校第二场 HDU 6040 Hints of sd0061 快速排序
- 2017 多校训练第一场 HDU 6040 Hints of sd0061
- HDU-2017 多校训练赛1-1008-Hints of sd0061
- HDU6040-Hints of sd0061
- HDU5785Hints of sd0061
- Hints of sd0061 HDU
- hdu 6040 Hints of sd0061[2017 Multi-University Training Contest
- 【多校训练】hdu 6040 Hints of sd0061 STL
- HDU 6040 Hints of sd0061
- [HDU]-6040 Hints of sd0061
- HDU 6040 Hints of sd0061
- HDU6040 Hints of sd0061【STL】
- HDU-6040 Hints of sd0061
- hdu 6040 Hints of sd0061
- hdu 6040 Hints of sd0061
- 【HDU6040】Hints of sd0061(nth_element)
- 2017多校一 1008题 hdu 6040 Hints of sd0061 排序 STL nth_element
- 如何跳过ZCL发送数据
- SPFA差分约束(bzoj 2330: [SCOI2011]糖果)
- Android视频滤镜添加硬解码方案
- 连接符
- Spring MVC拦截器(Interceptor)
- 2017多校联合一/hdu6040Hints of sd0061
- Spring Boot+Thymeleaf出现org.xml.sax.SAXParseException: 元素类型 "meta" 必须由匹配的结束标记 "</meta>" 终止。
- linux安装问题
- 获取字符串的长度
- 插入排序(insertSort.cpp)
- nyoj-37 回文字符串
- 输出错误日志
- Android Post方式提交数据
- jeecg excel 导入到java