結果
| 問題 | 
                            No.1379 Postponed
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-04-16 15:57:19 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 941 bytes | 
| コンパイル時間 | 268 ms | 
| コンパイル使用メモリ | 82,504 KB | 
| 実行使用メモリ | 848,900 KB | 
| 最終ジャッジ日時 | 2025-04-16 16:00:24 | 
| 合計ジャッジ時間 | 10,666 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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)))
            
            
            
        
            
lam6er