結果
問題 |
No.1379 Postponed
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:56:32 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 940 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 81,712 KB |
実行使用メモリ | 847,832 KB |
最終ジャッジ日時 | 2025-04-15 22:58:11 |
合計ジャッジ時間 | 9,135 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 40 MLE * 1 -- * 23 |
ソースコード
n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(' '.join(map(str, a))) exit() history = {} current = tuple(a) history[current] = 0 steps = 0 found_cycle = False while steps < k: x = a[0] m = x + 1 if m > len(a): rotated = a[1:] + [a[0]] else: rotated = a[1:m] + [a[0]] + a[m:] a = rotated steps += 1 current = tuple(a) if current in history: # Cycle detected prev_step = history[current] cycle_length = steps - prev_step remaining = (k - steps) % cycle_length for _ in range(remaining): x = a[0] m = x + 1 if m > len(a): rotated = a[1:] + [a[0]] else: rotated = a[1:m] + [a[0]] + a[m:] a = rotated found_cycle = True break else: history[current] = steps print(' '.join(map(str, a)))