問題一覧 > 通常問題

No.1013 Advance ○ Squares

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 130
作問者 : otamay6 / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 3604 / 自分の提出
問題文最終更新日: 2019-12-08 15:25:37
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 241 (順位表) の他の問題:

Problem Statement

You are given a permutation $P$ of {$1,2, \dots ,N$}.
Let $T$ be the sequence obtained by concatenating $10^{10}$ copies of $P$.
You perform the following action on $T$.
・When you are at the $i$-th element, move to the $i+T_i$-th element
For each starting position at the $i$-th element $(i=1,2, \dots ,N)$, after performing this action $K$ times,
determine which element you reach, for every $i$, and print each answer on its own line.

Input

$N\ K$
$P_1\ P_2\ \dots\ P_N$

The input is given as integers.
$ 1 \le N \le 10^5 $
$ 1 \le K \le 10^9 $
$P$ is a permutation of {$1, 2, \dots , N$}.

Output

$A_1$
$A_2$
$\vdots$
$A_N$

Print the answer $A_i$ to the problem for each $i (i=1,2, \dots , N)$ in the format above.
Print a newline at the end.

Sample

Sample 1
Input
5 2
1 2 3 4 5
Output
4
8
7
11
15

For example, if you start from the 3rd element, you advance as 3→6→7.

Sample 2
Input
4 2
1 2 3 4
Output
4
8
8
12

Sample 3
Input
10 6
1 9 5 10 2 4 3 8 7 6
Output
31
32
36
64
30
36
36
40
40
40

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。