博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 6040 Hints of sd0061 —— 2017 Multi-University Training 1
阅读量:6689 次
发布时间:2019-06-25

本文共 2662 字,大约阅读时间需要 8 分钟。

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 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 aisd0061 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+bjbk is satisfied if bibj, 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(1n107,1m100)
The second line contains m integers, the i-th of which is the number bi of the i-th hint. (0bi<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 #xy1 y2  ym" in one line (without quotes), where 
x indicates the case number starting from 1 and yi (1im) 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 40551
 
 
题目大意:用题目所给的程序生成a数组,m个询问,每个询问输出a从小至大排序后第bi个数。
思路:按照题意进行排序,不过输出ai前用sort会超时,用nth_element()可以避免TLE。
 
AC代码:
1 #include
2 #include
3 #include
4 #include
5 using namespace std; 6 const int MAXN=1e7+5; 7 unsigned n, m; 8 unsigned rat[MAXN], b[MAXN],p[MAXN], a[MAXN]; 9 unsigned x,y,z;10 unsigned rng61() {11 unsigned t;12 x ^= x << 16;13 x ^= x >> 5;14 x ^= x << 1;15 t = x;16 x = y;17 y = z;18 z = t ^ x ^ y;19 return z;20 }21 bool cmp(int s, int t)22 {23 return b[s]
=0;i--){40 if(b[p[i]]==b[p[i+1]]){41 a[p[i]]=a[p[i+1]];42 //continue;43 } 44 nth_element(rat, rat+b[p[i]], rat+b[p[i+1]]);45 a[p[i]]=rat[b[p[i]]];46 }47 printf("Case #%d:", ++k);48 for(int i=0;i

 

转载于:https://www.cnblogs.com/MasterSpark/p/7265938.html

你可能感兴趣的文章
linux ubuntu apt-get 更换源
查看>>
【Web探索之旅】第二部分第三课:框架和内容管理系统
查看>>
Javascript中公有成员,私有成员,静态成员
查看>>
包失效,无法编译
查看>>
docker笔记
查看>>
小白第三天
查看>>
2016年linux运维人员必会开源运维工具体系
查看>>
MIT透过机器学习技术用胺基酸预测蛋白质结构
查看>>
小型企业公司路由器做DHCP服务器
查看>>
JAVA数组和面向对象
查看>>
Microsoft Visual C++ Runtime library not enough space for thread data
查看>>
Centos 7 ntp时间服务器搭建
查看>>
电压电流采集模块,温湿度采集,称重模块,变送器,adc模数转换模块
查看>>
2019北京物联网智慧城市大数据博览会开启中国之路
查看>>
华为云网络服务两场景
查看>>
将 Desktop Central 与帮助台和 OS Deployer 集成
查看>>
技巧分享:caj怎么转化为pdf
查看>>
WebPack牛刀小试
查看>>
技巧: iPhone玩游戏手机发烫?有妙招
查看>>
SQL Server 2008高可用×××介绍
查看>>