結果

問題 No.326 あみだますたー
ユーザー tabataba
提出日時 2016-04-14 23:07:31
言語 Python2
(2.7.18)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-25 12:03:54
合計ジャッジ時間 1,550 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,272 KB
testcase_01 AC 9 ms
6,400 KB
testcase_02 AC 11 ms
6,528 KB
testcase_03 AC 31 ms
7,424 KB
testcase_04 AC 15 ms
6,656 KB
testcase_05 AC 10 ms
6,400 KB
testcase_06 AC 21 ms
6,912 KB
testcase_07 AC 14 ms
6,400 KB
testcase_08 AC 17 ms
7,040 KB
testcase_09 AC 30 ms
7,552 KB
testcase_10 AC 28 ms
7,424 KB
testcase_11 AC 10 ms
6,400 KB
testcase_12 AC 23 ms
6,784 KB
testcase_13 AC 25 ms
7,040 KB
testcase_14 AC 12 ms
6,400 KB
testcase_15 AC 17 ms
6,784 KB
testcase_16 AC 23 ms
6,912 KB
testcase_17 AC 15 ms
6,656 KB
testcase_18 AC 15 ms
6,528 KB
testcase_19 AC 22 ms
6,784 KB
testcase_20 AC 10 ms
6,400 KB
testcase_21 AC 10 ms
6,400 KB
testcase_22 AC 21 ms
7,040 KB
testcase_23 AC 19 ms
6,912 KB
testcase_24 AC 26 ms
7,168 KB
testcase_25 AC 23 ms
7,040 KB
testcase_26 AC 12 ms
6,400 KB
testcase_27 AC 21 ms
6,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=input()
k=input()
xy=[map(int,raw_input().split())for i in[k]*k]
a=[0]*n
t=map(int,raw_input().split())
for i in range(n):
	a[t[i]-1]=i+1
b=range(1,n+1)
for i in xy:
	x=i[0]-1
	y=i[1]-1
	b[x],b[y]=b[y],b[x]
#print b
t=[]
for i in range(n):
	for j in range(n-1,i,-1):
		if b[j]==a[i]:
			b[j],b[j-1]=b[j-1],b[j]
			t+=[[j-1,j]]
#print a,b,a==b
print len(t)
for i in t:
	print i[0]+1,i[1]+1
0