結果
| 問題 | No.1477 Lamps on Graph | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-04-17 11:46:46 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 800 bytes | 
| コンパイル時間 | 156 ms | 
| コンパイル使用メモリ | 82,480 KB | 
| 実行使用メモリ | 106,580 KB | 
| 最終ジャッジ日時 | 2024-07-03 18:37:10 | 
| 合計ジャッジ時間 | 14,553 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 2 | 
| other | WA * 38 | 
ソースコード
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=[]
print(edge,score,light)
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)
            
            
            
        