結果

問題 No.3775 Distant Swap
コンテスト
ユーザー 回転
提出日時 2026-10-23 22:18:10
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 66 ms / 2,000 ms
+ 849µs
コード長 381 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 571 ms
コンパイル使用メモリ 64,520 KB
実行使用メモリ 65,652 KB
最終ジャッジ日時 2026-10-23 22:18:15
合計ジャッジ時間 3,927 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

ans = []
while(True):
    flag = False
    for i in range(N-K):
        if(P[i] > P[i+K]):
            ans.append((i+1,i+K+1))
            P[i],P[i+K] = P[i+K],P[i]
            flag = True
    if(not flag):break

if(P == sorted(P)):
    print(len(ans))
    for i in ans:
        print(*i)
else:
    print(-1)
0