結果

問題 No.1854 Limited Bubble Sort
ユーザー rin204
提出日時 2022-03-21 04:12:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 482 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 62,844 KB
最終ジャッジ日時 2024-10-08 00:56:26
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    P = list(map(int, input().split()))
    ans = []
    for i in range(1, n):
        for j in range(i - 1, -1, -1):
            if P[j + 1] < P[j]:
                if P[j + 1] == j + 2 or P[j] == j + 1:
                    print(-1)
                    return
                ans.append(j + 1)
                P[j], P[j + 1] = P[j + 1], P[j]
                
    print(len(ans))
    print(*ans)
    
    
for _ in range(int(input())):
    solve()
0