結果

問題 No.326 あみだますたー
ユーザー titiatitia
提出日時 2023-01-16 00:42:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-08-28 15:23:31
合計ジャッジ時間 2,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,808 KB
testcase_01 AC 14 ms
7,768 KB
testcase_02 AC 16 ms
8,336 KB
testcase_03 AC 37 ms
8,460 KB
testcase_04 AC 20 ms
8,488 KB
testcase_05 AC 14 ms
7,928 KB
testcase_06 AC 24 ms
7,824 KB
testcase_07 AC 18 ms
7,780 KB
testcase_08 AC 23 ms
8,736 KB
testcase_09 AC 35 ms
8,744 KB
testcase_10 AC 33 ms
8,616 KB
testcase_11 AC 15 ms
7,924 KB
testcase_12 AC 27 ms
8,604 KB
testcase_13 AC 29 ms
8,544 KB
testcase_14 AC 17 ms
8,344 KB
testcase_15 AC 22 ms
7,832 KB
testcase_16 AC 27 ms
7,752 KB
testcase_17 AC 20 ms
8,400 KB
testcase_18 AC 21 ms
8,348 KB
testcase_19 AC 25 ms
7,832 KB
testcase_20 AC 15 ms
7,860 KB
testcase_21 AC 15 ms
7,748 KB
testcase_22 AC 26 ms
8,604 KB
testcase_23 AC 24 ms
8,480 KB
testcase_24 AC 31 ms
8,580 KB
testcase_25 AC 29 ms
8,496 KB
testcase_26 AC 17 ms
7,800 KB
testcase_27 AC 26 ms
8,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
K=int(input())

A=list(range(N+1))

for i in range(K):
    x,y=map(int,input().split())
    A[x],A[y]=A[y],A[x]

X=[0]+list(map(int,input().split()))

for i in range(N+1):
    A[i]=X[A[i]]

ANS=[]

for i in range(N+1):
    k=A.index(i)

    for j in range(k-1,i-1,-1):
        ANS.append((j,j+1))
        A[j],A[j+1]=A[j+1],A[j]

print(len(ANS))
for x,y in ANS:
    print(x,y)

0