結果

問題 No.1379 Postponed
ユーザー gew1fw
提出日時 2025-06-12 20:51:54
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,172 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,896 KB
実行使用メモリ 856,052 KB
最終ジャッジ日時 2025-06-12 20:56:24
合計ジャッジ時間 9,985 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 40 MLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    K = int(input[idx])
    idx += 1
    A0 = list(map(int, input[idx:idx+N]))
    idx += N

    if K == 0:
        print(' '.join(map(str, A0)))
        return

    def next_array(current):
        x = current[0]
        m = x + 1
        if m > len(current):
            m = len(current)
        rotated = current[1:m] + [current[0]]
        new_arr = rotated + current[m:]
        return new_arr

    seen = {}
    steps = [A0.copy()]
    seen[tuple(A0)] = 0

    for step in range(1, K + 1):
        current = next_array(steps[step - 1])
        tupled = tuple(current)
        if tupled in seen:
            start_step = seen[tupled]
            cycle_length = step - start_step
            remaining = K - start_step
            effective_step = (remaining % cycle_length) + start_step
            result = steps[effective_step]
            print(' '.join(map(str, result)))
            return
        else:
            seen[tupled] = step
            steps.append(current)

    print(' '.join(map(str, steps[K])))

if __name__ == '__main__':
    main()
0