結果

問題 No.429 CupShuffle
ユーザー magurogumamaguroguma
提出日時 2017-08-17 20:43:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 28,748 KB
最終ジャッジ日時 2024-04-22 14:51:52
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 34 ms
10,752 KB
testcase_07 AC 34 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 466 ms
28,608 KB
testcase_12 AC 429 ms
28,568 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

N,K,X = map(int, input().split())
A = []
B = []
for i in range(K):
    a,b = input().split()
    if a=='?':
        A.append(a)
        B.append(b)
    else:
        A.append(int(a))
        B.append(int(b))
C = list(map(int, input().split()))

first = list(range(N+1))
latter = [0]
for c in C:
    latter.append(c)

for i in range(K):
    if A[i] == '?':
        break
    temp = first[A[i]]
    first[A[i]] = first[B[i]]
    first[B[i]] = temp

for i in range(K-1, -1, -1):
    if A[i] == '?':
        break
    temp = latter[A[i]]
    latter[A[i]] = latter[B[i]]
    latter[B[i]] = temp

for i in range(1, N+1):
    if first[i] != latter[i]:
        print(i, first[latter[i]])
        break
0