結果

問題 No.429 CupShuffle
ユーザー nebukuro09nebukuro09
提出日時 2016-10-02 22:49:47
言語 Python2
(2.7.18)
結果
AC  
実行時間 465 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 6,584 KB
実行使用メモリ 31,232 KB
最終ジャッジ日時 2023-08-13 17:14:23
合計ジャッジ時間 2,959 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
6,064 KB
testcase_01 AC 12 ms
5,868 KB
testcase_02 AC 11 ms
6,044 KB
testcase_03 AC 10 ms
6,060 KB
testcase_04 AC 13 ms
6,004 KB
testcase_05 AC 10 ms
5,864 KB
testcase_06 AC 14 ms
6,028 KB
testcase_07 AC 14 ms
6,008 KB
testcase_08 AC 10 ms
5,980 KB
testcase_09 AC 13 ms
6,128 KB
testcase_10 AC 53 ms
8,116 KB
testcase_11 AC 465 ms
31,032 KB
testcase_12 AC 444 ms
31,004 KB
testcase_13 AC 463 ms
31,232 KB
testcase_14 AC 455 ms
31,120 KB
testcase_15 AC 10 ms
5,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K, X = map(int, raw_input().split())
swap = []
for _ in xrange(K):
    r = raw_input().split()
    if r[0] == ('?'):
        continue
    swap.append(map(lambda x:int(x)-1, r))
C = map(int, raw_input().split())

A = [i for i in xrange(1, N+1)]
for i in xrange(X-1):
    A[swap[i][0]], A[swap[i][1]] = A[swap[i][1]], A[swap[i][0]]

for i in xrange(K-2, X-2, -1):
    C[swap[i][0]], C[swap[i][1]] = C[swap[i][1]], C[swap[i][0]]


ans = []
for i in xrange(N):
    if A[i] != C[i]:
        ans.append(i)
print ans[0]+1, ans[1]+1
0