結果
問題 |
No.1379 Postponed
|
ユーザー |
![]() |
提出日時 | 2025-04-16 15:57:18 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 940 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 81,644 KB |
実行使用メモリ | 856,048 KB |
最終ジャッジ日時 | 2025-04-16 16:00:15 |
合計ジャッジ時間 | 9,889 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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)))