結果

問題 No.1477 Lamps on Graph
ユーザー gr1msl3ygr1msl3y
提出日時 2021-05-03 19:48:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 612 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 161,456 KB
最終ジャッジ日時 2023-09-29 16:06:11
合計ジャッジ時間 19,397 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,712 KB
testcase_01 AC 88 ms
71,612 KB
testcase_02 AC 88 ms
71,672 KB
testcase_03 AC 88 ms
71,480 KB
testcase_04 AC 88 ms
71,524 KB
testcase_05 AC 89 ms
71,552 KB
testcase_06 AC 87 ms
71,308 KB
testcase_07 AC 86 ms
71,776 KB
testcase_08 AC 88 ms
71,480 KB
testcase_09 AC 88 ms
71,628 KB
testcase_10 AC 88 ms
71,756 KB
testcase_11 AC 87 ms
71,560 KB
testcase_12 AC 373 ms
102,320 KB
testcase_13 AC 350 ms
109,872 KB
testcase_14 AC 386 ms
108,980 KB
testcase_15 AC 227 ms
88,508 KB
testcase_16 AC 234 ms
89,284 KB
testcase_17 AC 235 ms
88,476 KB
testcase_18 AC 461 ms
135,420 KB
testcase_19 AC 363 ms
111,232 KB
testcase_20 AC 200 ms
84,268 KB
testcase_21 AC 400 ms
114,064 KB
testcase_22 AC 177 ms
81,944 KB
testcase_23 AC 265 ms
91,056 KB
testcase_24 AC 465 ms
120,864 KB
testcase_25 AC 225 ms
87,668 KB
testcase_26 AC 476 ms
123,740 KB
testcase_27 AC 261 ms
91,132 KB
testcase_28 AC 325 ms
99,264 KB
testcase_29 AC 286 ms
93,984 KB
testcase_30 AC 276 ms
106,788 KB
testcase_31 AC 252 ms
94,388 KB
testcase_32 AC 577 ms
161,456 KB
testcase_33 AC 555 ms
157,500 KB
testcase_34 AC 329 ms
152,936 KB
testcase_35 AC 612 ms
139,516 KB
testcase_36 AC 609 ms
136,448 KB
testcase_37 AC 567 ms
127,992 KB
testcase_38 AC 583 ms
129,896 KB
testcase_39 AC 602 ms
136,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N, M = map(int, input().split())
A = [0]+list(map(int, input().split()))
task = [[0, 0]]+[[A[i], i] for i in range(1, N+1)]
task.sort()
Edges = defaultdict(set)
for _ in range(M):
    u, v = map(int, input().split())
    Edges[u].add(v)
    Edges[v].add(u)
K = int(input())
B = set(map(int, input().split()))
state = [int(i in B) for i in range(N+1)]
ans = []

for a, v in task:
    if not state[v]:
        continue
    state[v] = 0
    ans.append(v)
    for e in Edges[v]:
        if A[e] > a:
            state[e] ^= 1

if sum(state):
    print(-1)
else:
    print(len(ans))
    print(*ans, sep='\n')
0