結果

問題 No.1477 Lamps on Graph
ユーザー FromBooskaFromBooska
提出日時 2023-09-03 20:45:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 563 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 116,236 KB
最終ジャッジ日時 2023-09-03 20:45:37
合計ジャッジ時間 15,397 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,720 KB
testcase_01 AC 93 ms
71,652 KB
testcase_02 AC 96 ms
71,652 KB
testcase_03 AC 92 ms
71,792 KB
testcase_04 AC 91 ms
71,852 KB
testcase_05 AC 91 ms
71,652 KB
testcase_06 AC 91 ms
71,880 KB
testcase_07 AC 91 ms
71,704 KB
testcase_08 AC 92 ms
71,720 KB
testcase_09 AC 94 ms
71,612 KB
testcase_10 AC 91 ms
71,572 KB
testcase_11 AC 92 ms
71,648 KB
testcase_12 AC 332 ms
89,516 KB
testcase_13 AC 316 ms
93,124 KB
testcase_14 AC 362 ms
92,820 KB
testcase_15 AC 220 ms
82,916 KB
testcase_16 AC 239 ms
84,768 KB
testcase_17 AC 226 ms
84,916 KB
testcase_18 AC 414 ms
102,832 KB
testcase_19 AC 332 ms
92,504 KB
testcase_20 AC 192 ms
81,064 KB
testcase_21 AC 351 ms
93,092 KB
testcase_22 AC 174 ms
80,156 KB
testcase_23 AC 263 ms
86,932 KB
testcase_24 AC 427 ms
100,924 KB
testcase_25 AC 231 ms
85,028 KB
testcase_26 AC 453 ms
100,712 KB
testcase_27 AC 255 ms
88,376 KB
testcase_28 AC 306 ms
88,916 KB
testcase_29 AC 266 ms
86,796 KB
testcase_30 AC 284 ms
90,344 KB
testcase_31 AC 240 ms
86,520 KB
testcase_32 AC 510 ms
116,168 KB
testcase_33 AC 528 ms
115,540 KB
testcase_34 AC 267 ms
116,236 KB
testcase_35 AC 563 ms
108,820 KB
testcase_36 AC 539 ms
106,448 KB
testcase_37 AC 520 ms
99,940 KB
testcase_38 AC 524 ms
101,828 KB
testcase_39 AC 537 ms
106,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# a昇順で頂点を見ていく
# スイッチついていたら消す、そのときに連鎖先もスイッチ押す

N, M = map(int, input().split())
A = list(map(int, input().split()))
edges = [[] for i in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    edges[u-1].append(v-1)
    edges[v-1].append(u-1)
K = int(input())
B = list(map(int, input().split()))
switch = [0]*N
for b in B:
    switch[b-1] = 1

A_idx = []
for i in range(N):
    A_idx.append((A[i], i))
A_idx.sort()
    
from collections import deque
que = deque(A_idx)
#visited = [0]*N
ans_list = []
while que:
    ca, ci = que.popleft()
    if switch[ci] == 1:
        ans_list.append(ci)
        for nxt in edges[ci]:
            if A[nxt] > A[ci]:
                switch[nxt] ^= 1
print(len(ans_list))
for a in ans_list:
    print(a+1)




0