結果

問題 No.429 CupShuffle
ユーザー matsu7874
提出日時 2016-10-02 22:35:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 487 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 34,216 KB
最終ジャッジ日時 2024-11-21 13:17:08
合計ジャッジ時間 3,126 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k,x = map(int, input().split())
p = [[],[]]
t = 0
for i in range(k):
    if i+1 != x:
        a,b = map(int, input().split())
        p[t].append((a-1,b-1)) 
    else:
        _ = input()
        t = 1
c = list(map(int, input().split()))
a = [i+1 for i in range(n)]
for x,y in p[0]:
    a[x],a[y] = a[y],a[x]

for x,y in p[1][::-1]:
    c[x],c[y] = c[y],c[x]
ans = []
for i in range(n):
    if a[i] != c[i]:
        ans.append(i+1)
print(ans[0], ans[1])
0