結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-16 23:28:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 754 bytes |
| コンパイル時間 | 801 ms |
| コンパイル使用メモリ | 82,648 KB |
| 実行使用メモリ | 112,728 KB |
| 最終ジャッジ日時 | 2024-07-03 04:25:15 |
| 合計ジャッジ時間 | 14,290 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 27 |
ソースコード
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]:
edge[u].append(v)
if A[v]<A[u]:
edge[v].append(u)
K=int(input())
B=list(map(int,input().split()))
q=[]
ans=0
for i in B:
score[i-1]=1
q.append((A[i-1],i-1))
import heapq
heapq.heapify(q)
ans_l=[]
while q:
value,next=heapq.heappop(q)
if score[next]==-1:
continue
if score[next]%2==1:
ans+=1
ans_l.append(next)
for i in edge[next]:
if score[i]==-1:
continue
score[i]+=score[next]
heapq.heappush(q,(-1,i))
score[next]=-1
print(ans)
for i in ans_l:
print(i+1)