結果
問題 |
No.1379 Postponed
|
ユーザー |
![]() |
提出日時 | 2025-06-12 12:57:07 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 955 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,904 KB |
実行使用メモリ | 857,064 KB |
最終ジャッジ日時 | 2025-06-12 13:03:41 |
合計ジャッジ時間 | 10,472 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 = a.copy() steps = 0 found_cycle = False while steps < k: key = tuple(current) if key in history: prev_step = history[key] cycle_length = steps - prev_step remaining = k - steps remaining %= cycle_length k = remaining found_cycle = True break else: history[key] = steps a0 = current[0] m = a0 + 1 if m > len(current): m = len(current) new_current = current[1:m] + [current[0]] + current[m:] current = new_current steps += 1 if found_cycle: for _ in range(k): a0 = current[0] m = a0 + 1 if m > len(current): m = len(current) new_current = current[1:m] + [current[0]] + current[m:] current = new_current print(' '.join(map(str, current)))