結果

問題 No.429 CupShuffle
ユーザー noriocnorioc
提出日時 2016-10-02 23:40:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 41,196 KB
最終ジャッジ日時 2023-08-13 18:15:19
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,348 KB
testcase_01 AC 16 ms
7,788 KB
testcase_02 AC 16 ms
7,772 KB
testcase_03 AC 16 ms
7,864 KB
testcase_04 AC 18 ms
7,908 KB
testcase_05 AC 16 ms
7,836 KB
testcase_06 AC 19 ms
8,224 KB
testcase_07 AC 18 ms
8,216 KB
testcase_08 AC 15 ms
7,804 KB
testcase_09 AC 18 ms
7,752 KB
testcase_10 AC 48 ms
10,656 KB
testcase_11 AC 366 ms
37,064 KB
testcase_12 AC 332 ms
34,308 KB
testcase_13 AC 378 ms
41,196 KB
testcase_14 AC 347 ms
23,412 KB
testcase_15 AC 16 ms
7,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def readints():
    return list(map(int, input().split()))

def main():
    n, k, x = readints()

    xs = list(range(n))
    for i in range(x-1):
        a, b = readints()
        xs[a-1], xs[b-1] = xs[b-1], xs[a-1]

    input() # read X
    swaps = []
    for i in range(k - x):
        swaps.append(readints())

    ys = [i-1 for i in readints()]
    for a, b in reversed(swaps):
        ys[a-1], ys[b-1] = ys[b-1], ys[a-1]

    ans = []
    for i in range(len(xs)):
        if xs[i] != ys[i]:
            ans.append(i + 1)

    ans.sort()
    print(ans[0], ans[1])

main()
0