結果
問題 |
No.1013 〇マス進む
|
ユーザー |
|
提出日時 | 2022-10-30 16:55:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 188 ms / 2,000 ms |
コード長 | 613 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,504 KB |
実行使用メモリ | 142,692 KB |
最終ジャッジ日時 | 2024-07-07 08:20:28 |
合計ジャッジ時間 | 11,303 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 62 |
ソースコード
n, K = map(int, input().split()) P = list(map(int, input().split())) nex = [[0] * n for _ in range(30)] tot = [[0] * n for _ in range(30)] for i, p in enumerate(P): nex[0][i] = (i + p) % n tot[0][i] = p for i in range(1, 30): for j in range(n): nex[i][j] = nex[i - 1][nex[i - 1][j]] tot[i][j] = tot[i - 1][j] + tot[i - 1][nex[i - 1][j]] ans = [i for i in range(1, n + 1)] pos = [i for i in range(n)] for i in range(29, -1, -1): if not K >> i & 1: continue for j in range(n): ans[j] += tot[i][pos[j]] pos[j] = nex[i][pos[j]] print(*ans, sep="\n")