結果

問題 No.326 あみだますたー
ユーザー nebukuro09
提出日時 2016-11-01 12:32:37
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 490 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 00:41:44
合計ジャッジ時間 5,119 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 3 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
K = input()
amida = range(1, N+1)
for i in xrange(K):
    x, y = map(int, raw_input().split())
    amida[x-1], amida[y-1] = amida[y-1], amida[x-1]
seikai = sorted((a, i+1) for i, a in enumerate(map(int, raw_input().split())))

ans = []
for pos, i in seikai:
    cur = amida.index(i)
    while cur+1 > pos:
        ans.append((cur, cur+1))
        amida[cur], amida[cur-1] = amida[cur-1], amida[cur]
        cur -= 1
#print amida        
print len(ans)
for a in ans:
    print a
0