結果

問題 No.1477 Lamps on Graph
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-02 04:36:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 792 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 59,552 KB
最終ジャッジ日時 2023-09-27 18:36:09
合計ジャッジ時間 15,254 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,788 KB
testcase_01 AC 16 ms
7,936 KB
testcase_02 AC 14 ms
7,900 KB
testcase_03 AC 14 ms
7,764 KB
testcase_04 AC 14 ms
7,684 KB
testcase_05 AC 14 ms
7,792 KB
testcase_06 AC 15 ms
7,936 KB
testcase_07 AC 14 ms
7,756 KB
testcase_08 AC 14 ms
7,844 KB
testcase_09 AC 15 ms
7,784 KB
testcase_10 AC 15 ms
7,844 KB
testcase_11 AC 15 ms
7,912 KB
testcase_12 AC 451 ms
37,300 KB
testcase_13 AC 390 ms
34,484 KB
testcase_14 AC 541 ms
42,124 KB
testcase_15 AC 250 ms
23,920 KB
testcase_16 AC 139 ms
21,740 KB
testcase_17 AC 131 ms
20,292 KB
testcase_18 AC 395 ms
41,504 KB
testcase_19 AC 325 ms
34,708 KB
testcase_20 AC 157 ms
18,192 KB
testcase_21 AC 315 ms
36,272 KB
testcase_22 AC 131 ms
15,068 KB
testcase_23 AC 326 ms
27,452 KB
testcase_24 AC 605 ms
46,544 KB
testcase_25 AC 230 ms
21,664 KB
testcase_26 AC 536 ms
45,540 KB
testcase_27 AC 276 ms
26,644 KB
testcase_28 AC 330 ms
32,252 KB
testcase_29 AC 303 ms
28,744 KB
testcase_30 AC 189 ms
25,020 KB
testcase_31 AC 146 ms
21,984 KB
testcase_32 AC 769 ms
58,164 KB
testcase_33 AC 742 ms
57,560 KB
testcase_34 AC 604 ms
54,952 KB
testcase_35 AC 773 ms
59,552 KB
testcase_36 AC 739 ms
59,076 KB
testcase_37 AC 699 ms
57,200 KB
testcase_38 AC 737 ms
57,732 KB
testcase_39 AC 792 ms
59,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = [int(s) for s in input().split()]
V = [[int(i)-1 for i in input().split()] for m in range(M)]

K = int(input())
B = [int(s) for s in input().split()]

X = [0]*N

for i in range(N):
    X[i] = []

L = [0]*N

for i in range(M):
    a = V[i][0]
    b = V[i][1]
    if A[a] < A[b]:
        X[a].append(b)
    else:
        if A[b] < A[a]:
            X[b].append(a)

for j in range(len(B)):
    L[B[j]-1] = 1

A, C = (list(t) for t in zip(*sorted(zip(A, list(range(N))))))

Y = []

for i in range(N):
    if L[C[i]]%2 == 1:
        L[C[i]] = 0
        Y.append(C[i]+1)
        for j, item in enumerate(X[C[i]]):
            L[item] = (L[item]+1)%2

print(len(Y))
for i in range(len(Y)):
    print(Y[i])
0