#9805. [POI 2010] ZAB-Frog

    ID: 9805 传统题 1000ms 125MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P3509动态规划 DP2010倍增单调队列POI(波兰)深度优先搜索 DFS

[POI 2010] ZAB-Frog

[POI 2010] ZAB-Frog

题目描述

On the bed of one particularly long and straight Byteotian brook there lie $n$ rocks jutting above the water level. Their distances from the brook's spring are $p_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 $p_i$, then it will leap onto such $p_j$ that: $$ |\{ p_a : |p _ a - p _ i| k $$ If $p_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 $m$ leaps depending on the rock is started from?

输入格式

The first line of the standard input holds three integers, $n$, $k$ and $m$ ($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 $k$, and the number of intended leaps. The second line holds $n$ integers $p_j$ ($1 \le p_1 < p_2 < \cdots

输出格式

Your program should print a single line on the standard output, with $n$ integers $r_1, r_2, \cdots, r_n$ from the interval $[1, n]$ in it, separated by single spaces. The number $r_i$ denotes the number of the rock that the frog ends on after making $m$ leaps starting from the rock no. $i$ (in the input order).
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. 标签: P3509|动态规划 DP|2010|倍增|单调队列|POI(波兰)|深度优先搜索 DFS

来源

P3509|[POI 2010] ZAB-Frog