結果

問題 No.1477 Lamps on Graph
ユーザー brthyyjpbrthyyjp
提出日時 2021-08-30 20:15:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 719 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 102,408 KB
最終ジャッジ日時 2024-05-03 05:41:10
合計ジャッジ時間 10,524 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,480 KB
testcase_01 AC 41 ms
52,864 KB
testcase_02 AC 34 ms
53,120 KB
testcase_03 WA -
testcase_04 AC 33 ms
52,608 KB
testcase_05 AC 34 ms
52,608 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 44 ms
52,608 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 35 ms
52,608 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, m = map(int, input().split())
A = list(map(int, input().split()))
g = [[] for i in range(n)]
for i in range(m):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    if A[u] < A[v]:
        g[u].append(v)
    elif A[u] > A[v]:
        g[v].append(u)
k = int(input())
B = list(map(int, input().split()))
B = [b-1 for b in B]
C = [0]*n
for b in B:
    C[b] = 1

q = []
import heapq
for b in B:
    q.append((A[b], b))
ans = []
while q:
    a, v =heapq.heappop(q)
    if C[v] == 0:
        continue
    ans.append(v+1)
    for u in g[v]:
        C[u] = 1-C[u]
        q.append((A[u], u))
print(len(ans))
print(*ans, sep='\n')
0