結果
| 問題 | 
                            No.1379 Postponed
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 12:55:00 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,204 bytes | 
| コンパイル時間 | 179 ms | 
| コンパイル使用メモリ | 82,684 KB | 
| 実行使用メモリ | 674,292 KB | 
| 最終ジャッジ日時 | 2025-06-12 12:59:41 | 
| 合計ジャッジ時間 | 9,036 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 40 MLE * 1 -- * 23 | 
ソースコード
def main():
    import sys
    N, K = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split()))
    if K == 0:
        print(' '.join(map(str, A)))
        return
    
    history = {}
    current = A.copy()
    history[tuple(current)] = 0
    steps = 0
    found_cycle = False
    
    while steps < K:
        s_prev = current[0]
        m = s_prev + 1
        next_arr = current[1:m] + [current[0]] + current[m:]
        steps += 1
        key = tuple(next_arr)
        if key in history:
            prev_step = history[key]
            cycle_len = steps - prev_step
            remaining = K - steps
            remaining %= cycle_len
            K = prev_step + remaining
            current = next_arr.copy()
            for _ in range(K - prev_step):
                s_prev = current[0]
                m = s_prev + 1
                next_arr = current[1:m] + [current[0]] + current[m:]
                current = next_arr.copy()
            print(' '.join(map(str, current)))
            return
        else:
            history[key] = steps
            current = next_arr.copy()
    
    print(' '.join(map(str, current)))
if __name__ == "__main__":
    main()
            
            
            
        
            
gew1fw