結果

問題 No.1477 Lamps on Graph
ユーザー 8nd5t8nd5t
提出日時 2021-04-16 20:39:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,129 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 120,204 KB
最終ジャッジ日時 2023-09-15 21:37:27
合計ジャッジ時間 13,907 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,452 KB
testcase_01 AC 94 ms
71,728 KB
testcase_02 AC 94 ms
71,960 KB
testcase_03 WA -
testcase_04 AC 93 ms
71,712 KB
testcase_05 AC 94 ms
71,452 KB
testcase_06 WA -
testcase_07 AC 92 ms
71,524 KB
testcase_08 AC 93 ms
71,928 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 94 ms
71,620 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 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 253 ms
119,728 KB
testcase_33 WA -
testcase_34 AC 221 ms
120,204 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,math,itertools
from collections import Counter,deque,defaultdict
from bisect import bisect_left,bisect_right 
from heapq import heappop,heappush,heapify
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_1(): return list(map(lambda x:int(x)-1, sys.stdin.readline().split()))
def inps(): return sys.stdin.readline()
def inpsl(x): tmp = sys.stdin.readline(); return list(tmp[:x])
def err(x): print(x); exit()

n,m = inpl()
a = inpl()
g = [[] for _ in range(n)]
ny = [0]*n
for _ in range(m):
    u,v = inpl_1()
    if a[u] == a[v]: continue
    if a[u] > a[v]: u,v = v,u
    g[u].append(v)
    ny[v] += 1
k = inp()
b = set(inpl())
q = deque([])
seen = [0]*n
res = []
for i,x in enumerate(ny):
    if x == 0:
        q.append((i,0))
        seen[i] = 1
while q:
    u,c = q.popleft()
    now = (u+1 in b) ^ c
    if now: res.append(u+1)
    for v in g[u]:
        if seen[v]: continue
        ny[v] -= 1
        if ny[v] == 0:
            q.append((v,now))
            seen[v] = 1
print(len(res))
for x in res:
    print(x)
0