第一场 B Hints of sd0061

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 mm coming contests. sd0061 has left a set of hints for them.

There are nn noobs in the team, the ii-th of which has a rating aiai. sd0061 prepares one hint for each contest. The hint for the jj-th contest is a number bjbj, which means that the noob with the (bj+1)(bj+1)-th lowest rating is ordained by sd0061 for the jj-th contest.

The coach asks constroy to make a list of contestants. constroy looks into these hints and finds out: bi+bj≤bkbi+bj≤bk is satisfied if bi≠bj,bi≠bj, bi<bkbi<bk and bj<bkbj<bk.

Now, you are in charge of making the list for constroy.

InputThere are multiple test cases (about 1010).

For each test case:

The first line contains five integers n,m,A,B,Cn,m,A,B,C. (1≤n≤107,1≤m≤100)(1≤n≤107,1≤m≤100)

The second line contains mm integers, the ii-th of which is the number bibi of the ii-th hint. (0≤bi<n)(0≤bi<n)

The nn noobs‘ ratings are obtained by calling following function nn times, the ii-th result of which is aiai.

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;}

OutputFor each test case, output " Case #xx: y1y1 y2y2 ?? ymym" in one line (without quotes), where xx indicates the case number starting from 11 and yiyi (1≤i≤m)(1≤i≤m) denotes the rating of noob for the ii-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

题目大意:使用题目中给出的生成函数,生成n个数,然后给出m个bi打印n个数中第bi+1大的数。

解题思路:对bi进行由小到大排序,然后从m到0使用nth_element进行查找,找出bi+1大的数

AC代码:
时间: 2024-08-13 01:30:33

第一场 B Hints of sd0061的相关文章

2015 ACM多校训练第一场

在下面网址看效果更佳>_< http://mlz000.github.io/2015/08/07/2015-ACM%E5%A4%9A%E6%A0%A1%E8%AE%AD%E7%BB%83%E7%AC%AC%E4%B8%80%E5%9C%BA/ 题外话 这个暑假以前就决定要把这次多校的所有题全补了,中间断断续续,总算把第一场的题补全了,鄙视一下颓废的自己... hdu 5288(1001) OO's Sequence Solution 水题,定义两个数组L[i],R[i]示第i个数左侧和右侧最接

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

计蒜之道2015程序设计大赛初赛第一场——搜狗输入法的分词算法

(一)题面 计蒜之道2015程序设计大赛初赛第一场——搜狗输入法的分词算法 搜狗输入法最近的用户输入中出现了一种新的输入模式,形如 “0k1234567”,搜狗的工程师发现这一模式后了解到,这是一种新被提出的对于十五进制数字的标记模式,其中 “0k” 是标记进制为15的前缀标记,之后的部分 “1234567” 是实际的十五进制的数字串. 在发现这一标记模式后,搜狗的工程师开始尝试在已有的分词算法上进一步加入对于十五进制数字串的处理,把网页上的这种形式的 15 进制数正确地提取出来.我们知道,标记

2014多校第一场A题 || HDU 4861 Couple doubi

题目链接 题意 : 有K个球,给你一个数P,可以求出K个值,(i=1,2,...,k) : 1^i+2^i+...+(p-1)^i (mod p).然后女朋友先取,再xp取,都希望赢,如果女朋友能赢输出YES,否则输出NO 思路 :这个题,在纸上算算差不多就出来结果了,因为要赢,所以一开始必定拿大的,根据规律可以发现最后的那个取余结果不是0就是某个数,所以就看那个数有奇数个还是偶数个即可. 官方题解: 1 #include <stdio.h> 2 #include <string.h&g

HDU 4508 湫湫系列故事——减肥记I (2013腾讯编程马拉松初赛第一场)

http://acm.hdu.edu.cn/showproblem.php?pid=4508 题目大意: 给定一些数据. 每组数据以一个整数n开始,表示每天的食物清单有n种食物. 接下来n行,每行两个整数a和b,其中a表示这种食物可以带给湫湫的幸福值(数值越大,越幸福),b表示湫湫吃这种食物会吸收的卡路里量. 最后是一个整数m,表示湫湫一天吸收的卡路里不能超过m. 思路: 完全背包. 一开始以为是01背包. 敲了01后样例2不对啊!!! 然后改成完全就过了..就改循环体就好了.. #includ

计蒜之道 初赛第一场B 阿里天池的新任务(简单)

阿里“天池”竞赛平台近日推出了一个新的挑战任务:对于给定的一串 DNA 碱基序列 tt,判断它在另一个根据规则生成的 DNA 碱基序列 ss 中出现了多少次. 首先,定义一个序列 ww: \displaystyle w_{i} = \begin{cases}b, & i = 0\\(w_{i-1} + a) \mod n, & i > 0\end{cases}w?i??={?b,?(w?i−1??+a)modn,???i=0?i>0?? 接下来,定义长度为 nn 的 DNA 碱

2014多校第一场 I 题 || HDU 4869 Turn the pokers(费马小定理+快速幂模)

题目链接 题意 : m张牌,可以翻n次,每次翻xi张牌,问最后能得到多少种形态. 思路 :0定义为反面,1定义为正面,(一开始都是反), 对于每次翻牌操作,我们定义两个边界lb,rb,代表每次中1最少时最少的个数,rb代表1最多时的个数.一张牌翻两次和两张牌翻一次 得到的奇偶性相同,所以结果中lb和最多的rb的奇偶性相同.如果找到了lb和rb,那么,介于这两个数之间且与这两个数奇偶性相同的数均可取到,然后在这个区间内求组合数相加(若lb=3,rb=7,则3,5,7这些情况都能取到,也就是说最后的

2017 计蒜之道 初赛 第一场 B.阿里天池的新任务

2017 计蒜之道 初赛 第一场 B.阿里天池的新任务 1 /* QYP kuai wo dai ma*/ 2 #include<algorithm> 3 #include<iostream> 4 #include<iomanip> 5 #include<cstring> 6 #include<cstdlib> 7 #include<cstdio> 8 #include<queue> 9 #include<ctime

hdu 5288||2015多校联合第一场1001题

http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i