結果

問題 No.429 CupShuffle
ユーザー nanaenanae
提出日時 2017-02-02 18:05:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 1,064 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 37,228 KB
最終ジャッジ日時 2023-08-25 18:07:14
合計ジャッジ時間 2,438 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,528 KB
testcase_01 AC 13 ms
8,296 KB
testcase_02 AC 13 ms
8,492 KB
testcase_03 AC 13 ms
8,420 KB
testcase_04 AC 15 ms
8,096 KB
testcase_05 AC 14 ms
8,012 KB
testcase_06 AC 15 ms
8,464 KB
testcase_07 AC 16 ms
8,488 KB
testcase_08 AC 14 ms
8,304 KB
testcase_09 AC 16 ms
8,364 KB
testcase_10 AC 42 ms
11,304 KB
testcase_11 AC 308 ms
37,084 KB
testcase_12 AC 288 ms
37,100 KB
testcase_13 AC 296 ms
37,228 KB
testcase_14 AC 304 ms
37,196 KB
testcase_15 AC 14 ms
8,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import log

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, K, X = map(int, input().split())
    start = list(range(1, N + 1))
    zenhan = []
    kouhan = []

    for i in range(X - 1):
        A, B = map(int, input().split())
        zenhan.append((A, B))

    input()

    for i in range(K - X):
        A, B = map(int, input().split())
        kouhan.append((A, B))

    kouhan.reverse()

    end = [int(i) for i in input().split()]

    for i in range(X - 1):
        A, B = zenhan[i]
        start[A - 1], start[B - 1] = start[B - 1], start[A - 1]

    for i in range(K - X):
        A, B = kouhan[i]
        end[A - 1], end[B - 1] = end[B - 1], end[A - 1]

    # debug(start, locals())
    # debug(end, locals())

    ans = []

    for i in range(N):
        if start[i] != end[i]:
            ans.append(i + 1)
            
    print(*ans)

    pass

if __name__ == '__main__':
    solve()
0