結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-17 11:47:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,092 KB |
| 実行使用メモリ | 107,020 KB |
| 最終ジャッジ日時 | 2024-07-03 18:38:31 |
| 合計ジャッジ時間 | 7,941 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 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=[]
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)