結果

問題 No.326 あみだますたー
ユーザー 👑 H20H20
提出日時 2021-11-24 14:38:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 9,168 KB
最終ジャッジ日時 2023-09-09 06:47:20
合計ジャッジ時間 2,504 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,776 KB
testcase_01 AC 15 ms
7,984 KB
testcase_02 AC 17 ms
8,200 KB
testcase_03 AC 37 ms
9,092 KB
testcase_04 AC 20 ms
8,460 KB
testcase_05 AC 16 ms
7,940 KB
testcase_06 AC 27 ms
8,420 KB
testcase_07 AC 20 ms
8,380 KB
testcase_08 AC 23 ms
8,384 KB
testcase_09 AC 36 ms
9,168 KB
testcase_10 AC 35 ms
8,928 KB
testcase_11 AC 16 ms
7,772 KB
testcase_12 AC 26 ms
8,664 KB
testcase_13 AC 30 ms
9,100 KB
testcase_14 AC 18 ms
8,228 KB
testcase_15 AC 24 ms
8,448 KB
testcase_16 AC 31 ms
8,804 KB
testcase_17 AC 21 ms
8,652 KB
testcase_18 AC 21 ms
8,440 KB
testcase_19 AC 27 ms
8,784 KB
testcase_20 AC 16 ms
7,844 KB
testcase_21 AC 15 ms
7,872 KB
testcase_22 AC 28 ms
8,756 KB
testcase_23 AC 26 ms
8,684 KB
testcase_24 AC 33 ms
9,164 KB
testcase_25 AC 30 ms
8,964 KB
testcase_26 AC 19 ms
8,292 KB
testcase_27 AC 28 ms
8,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

XY = [list(map(int,input().split())) for _ in range(int(input()))]
AMIDA = [0]+list(map(int,input().split()))

for x,y in XY:
    AMIDA[x],AMIDA[x+1] = AMIDA[x+1],AMIDA[x]
ANS = []
for i in range(N+1):
    pos = AMIDA.index(i)
    for j in reversed(range(i,pos)):
        ANS.append(j)
        AMIDA[j],AMIDA[j+1] = AMIDA[j+1],AMIDA[j]
print(len(ANS))
for ans in ANS:
    print(ans,ans+1)

0