#P3509. [POI2010] ZAB-Frog

    ID: 2563 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划,dp2010倍增POI深度优先搜索,DFS

[POI2010] ZAB-Frog

题目描述

On the bed of one particularly long and straight Byteotian brook there lie nn rocks jutting above the water level. Their distances from the brook's spring are p1<p2<<pnp_1 < p_2 < \cdots < p_n respectively. A small frog sitting on one of these is about to begin its leaping training. Each time the frog leaps to the rock that is the -th closest to the one it is sitting on. Specifically, if the frog is sitting on the rock at position pip_i, then it will leap onto such pjp_j that:

$$|\{ p_a : |p _ a - p _ i| < |p_j - p_i| \}| \le k \text{ and } |\{ p_a : |p _ a - p _ i| \le |p_j - p_i| \}| > k $$

If pjp_j is not unique, then the frog chooses among them the rock that is closest to the spring. On which rock the frog will be sitting after mm leaps depending on the rock is started from?

输入格式

The first line of the standard input holds three integers, nn, kk and mm ($1 \le k < n \le 1 \, 000 \, 000, 1 \le m \le 10^{18}$), separated by single spaces, that denote respectively: the number of rocks, the parameter kk, and the number of intended leaps. The second line holds nn integers pjp_j (1p1<p2<<pn10181 \le p_1 < p_2 < \cdots < p_n \le 10^{18}), separated by single spaces, that denote the positions of successive rocks on the bed of the brook.

输出格式

Your program should print a single line on the standard output, with nn integers r1,r2,,rnr_1, r_2, \cdots, r_n from the interval [1,n][1, n] in it, separated by single spaces. The number rir_i denotes the number of the rock that the frog ends on after making mm leaps starting from the rock no. ii (in the input order).

题目大意

nn 个点,升序给出每个点到起点的距离。有编号为 1n1 \sim nnn 只青蛙分别在第 1n1 \sim n 个点上,每次它们会跳到距离自己第 kk 近的点上。

如果有相同距离的点,就跳到下标更小的点上。

求跳 mm 次之后,第 ii 只的青蛙在哪个点上。

输入共一行三个整数:代表 n,k,mn, k, m

输出共一行 nn 个整数,代表每只青蛙最终所处在的点。

5 2 4
1 2 4 7 10
1 1 3 1 1

提示

样例 #1 解释:

The figure presents where the frog leaps to (in a single leap) from each and every rock.