結果

問題 No.429 CupShuffle
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-02 14:17:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 96,896 KB
最終ジャッジ日時 2023-09-28 04:34:47
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,464 KB
testcase_01 AC 61 ms
71,360 KB
testcase_02 AC 63 ms
71,240 KB
testcase_03 AC 59 ms
71,288 KB
testcase_04 AC 71 ms
71,196 KB
testcase_05 AC 62 ms
71,120 KB
testcase_06 AC 75 ms
75,260 KB
testcase_07 AC 75 ms
74,912 KB
testcase_08 AC 60 ms
71,264 KB
testcase_09 AC 73 ms
75,468 KB
testcase_10 AC 110 ms
77,788 KB
testcase_11 AC 158 ms
96,168 KB
testcase_12 AC 155 ms
96,896 KB
testcase_13 AC 154 ms
96,644 KB
testcase_14 AC 151 ms
95,816 KB
testcase_15 AC 60 ms
71,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, x = map(int, input().split())
X = []
Y = []
for i in range(k):
    a, b = map(str, input().split())
    if i+1 < x:
        a, b = int(a), int(b)
        a, b = a-1, b-1
        X.append((a, b))
    elif i+1 > x:
        a, b = int(a), int(b)
        a, b = a-1, b-1
        Y.append((a, b))
D = list(range(1, n+1))
C = list(map(int, input().split()))
for a, b in X:
    D[a], D[b] = D[b], D[a]
Y.reverse()
for a, b in Y:
    C[a], C[b] = C[b], C[a]
ans = []
for i in range(n):
    if C[i] != D[i]:
        ans.append(i+1)
print(*ans)
0