結果

問題 No.429 CupShuffle
コンテスト
ユーザー matsu7874
提出日時 2016-10-02 22:35:28
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 348 ms / 2,000 ms
コード長 455 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 503 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 37,292 KB
最終ジャッジ日時 2026-05-15 17:04:54
合計ジャッジ時間 3,946 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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