結果

問題 No.429 CupShuffle
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-10-02 22:43:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 95,444 KB
最終ジャッジ日時 2023-08-13 17:10:17
合計ジャッジ時間 3,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
76,972 KB
testcase_01 AC 93 ms
71,880 KB
testcase_02 AC 93 ms
71,440 KB
testcase_03 AC 93 ms
71,876 KB
testcase_04 AC 106 ms
72,424 KB
testcase_05 AC 94 ms
71,988 KB
testcase_06 AC 110 ms
77,044 KB
testcase_07 AC 110 ms
76,908 KB
testcase_08 AC 92 ms
71,984 KB
testcase_09 AC 110 ms
76,916 KB
testcase_10 AC 145 ms
78,916 KB
testcase_11 AC 204 ms
94,948 KB
testcase_12 AC 198 ms
94,344 KB
testcase_13 AC 205 ms
95,444 KB
testcase_14 AC 195 ms
92,816 KB
testcase_15 AC 93 ms
71,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import collections


def main():
    n, k, x = map(int, input().split())
    cups = list(range(n))
    after = collections.deque()
    for i in range(k):
        if i != x - 1:
            a, b = map(lambda c: int(c) - 1, input().split())
            if i < x - 1:
                cups[a], cups[b] = cups[b], cups[a]
            else:
                after.append((a, b))
        else:
            _ = input()
    final_cups = list(map(lambda c: int(c) - 1, input().split()))
    while after:
        a, b = after.pop()
        final_cups[a], final_cups[b] = final_cups[b], final_cups[a]
    ans = []
    for j in range(n):
        if cups[j] != final_cups[j]:
            ans.append(j + 1)
    print(*ans)


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