結果

問題 No.429 CupShuffle
ユーザー rpy3cpprpy3cpp
提出日時 2016-10-05 00:50:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 401 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 39,384 KB
最終ジャッジ日時 2023-08-13 23:02:01
合計ジャッジ時間 3,307 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,228 KB
testcase_01 AC 16 ms
7,768 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 16 ms
7,908 KB
testcase_04 AC 18 ms
8,364 KB
testcase_05 AC 15 ms
7,864 KB
testcase_06 AC 19 ms
8,216 KB
testcase_07 AC 19 ms
8,248 KB
testcase_08 AC 16 ms
7,896 KB
testcase_09 AC 18 ms
8,184 KB
testcase_10 AC 49 ms
11,216 KB
testcase_11 AC 401 ms
39,376 KB
testcase_12 AC 374 ms
39,324 KB
testcase_13 AC 399 ms
39,380 KB
testcase_14 AC 396 ms
39,384 KB
testcase_15 AC 16 ms
7,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, K, X = map(int, input().split())
    ABs = []
    CDs = []
    for i in range(1, K + 1):
        if i < X:
            ABs.append(list(map(int, input().split())))
        elif i > X:
            CDs.append(list(map(int, input().split())))
        else:
            input()
    Cs = list(map(int, input().split()))
    return N, K, X, ABs, CDs, Cs

def solve(N, K, X, ABs, CDs, Cs):
    As = list(range(1, N + 1))
    for A, B in ABs:
        A -= 1
        B -= 1
        As[A], As[B] = As[B], As[A]
    CDs.reverse()
    for A, B in CDs:
        A -= 1
        B -= 1
        Cs[A], Cs[B] = Cs[B], Cs[A]
    pos = []
    p = 0
    for a, c in zip(As, Cs):
        p += 1
        if a != c:
            pos.append(p)
    return pos

params = read_data()
print(*solve(*params))
0