結果
問題 |
No.1379 Postponed
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:56:17 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 941 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 848,700 KB |
最終ジャッジ日時 | 2025-04-15 22:58:01 |
合計ジャッジ時間 | 10,295 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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() memo = {} current = tuple(a) memo[current] = 0 steps = 0 history = [a.copy()] cycle_found = False while steps < k: x = current[0] m = x + 1 new_list = list(current)[1:m] + [current[0]] + list(current)[m:] steps += 1 new_tuple = tuple(new_list) if new_tuple in memo: prev_step = memo[new_tuple] cycle_length = steps - prev_step remaining = (k - steps) % cycle_length for _ in range(remaining): x = new_list[0] m = x + 1 new_list = new_list[1:m] + [new_list[0]] + new_list[m:] print(' '.join(map(str, new_list))) cycle_found = True break else: memo[new_tuple] = steps current = new_tuple history.append(new_list) if not cycle_found: print(' '.join(map(str, current)))