結果

問題 No.1477 Lamps on Graph
ユーザー NoaSaberNoaSaber
提出日時 2021-04-17 11:47:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 105,672 KB
最終ジャッジ日時 2023-09-16 19:10:07
合計ジャッジ時間 11,269 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,648 KB
testcase_01 AC 93 ms
71,448 KB
testcase_02 AC 92 ms
71,572 KB
testcase_03 AC 92 ms
71,572 KB
testcase_04 AC 93 ms
71,888 KB
testcase_05 AC 92 ms
71,816 KB
testcase_06 AC 93 ms
71,756 KB
testcase_07 AC 92 ms
71,668 KB
testcase_08 AC 90 ms
71,812 KB
testcase_09 AC 93 ms
71,672 KB
testcase_10 AC 93 ms
71,788 KB
testcase_11 AC 93 ms
71,768 KB
testcase_12 AC 259 ms
86,700 KB
testcase_13 AC 251 ms
90,512 KB
testcase_14 AC 280 ms
88,484 KB
testcase_15 AC 213 ms
84,992 KB
testcase_16 AC 183 ms
84,096 KB
testcase_17 AC 187 ms
84,020 KB
testcase_18 AC 233 ms
97,584 KB
testcase_19 AC 233 ms
87,984 KB
testcase_20 AC 186 ms
80,184 KB
testcase_21 AC 212 ms
92,484 KB
testcase_22 AC 180 ms
82,796 KB
testcase_23 AC 229 ms
83,640 KB
testcase_24 AC 290 ms
95,664 KB
testcase_25 AC 206 ms
82,368 KB
testcase_26 AC 268 ms
93,020 KB
testcase_27 AC 227 ms
86,208 KB
testcase_28 AC 236 ms
87,788 KB
testcase_29 AC 233 ms
86,416 KB
testcase_30 AC 171 ms
86,792 KB
testcase_31 AC 184 ms
84,876 KB
testcase_32 AC 253 ms
105,672 KB
testcase_33 AC 247 ms
103,032 KB
testcase_34 AC 223 ms
99,020 KB
testcase_35 AC 325 ms
97,252 KB
testcase_36 AC 325 ms
95,716 KB
testcase_37 AC 316 ms
95,796 KB
testcase_38 AC 319 ms
96,132 KB
testcase_39 AC 331 ms
95,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))
edge=[[] for i in range(N)]
score=[0]*N
for i in range(M):
    u,v=map(int,input().split())
    u-=1;v-=1
    if A[u]<A[v]:
        score[v]+=1
        edge[u].append(v)
    if A[v]<A[u]:
        score[u]+=1
        edge[v].append(u)
K=int(input())
B=list(map(int,input().split()))
from collections import deque
q=deque([])
light=[0]*N
for i in B:
    light[i-1]=1
ans_l=[]
for i in range(N):
    if score[i]==0:
        q.append(i)
while q:
    first=q.popleft()
    if light[first]%2==1:
        ans_l.append(first)
    for i in edge[first]:
        if light[first]%2==1:
            light[i]+=1
        score[i]-=1
        if score[i]==0:
            q.append(i)
print(len(ans_l))
for i in ans_l:
    print(i+1)
0