結果
| 問題 | No.1477 Lamps on Graph |
| コンテスト | |
| ユーザー |
yuusanlondon
|
| 提出日時 | 2021-04-16 20:24:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 296 ms / 2,000 ms |
| コード長 | 657 bytes |
| 記録 | |
| コンパイル時間 | 522 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 119,016 KB |
| 最終ジャッジ日時 | 2026-03-24 06:16:38 |
| 合計ジャッジ時間 | 8,251 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 38 |
ソースコード
import os,io,heapq
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
graph=[]
for i in range(n):
graph.append([])
for i in range(m):
c,d=map(int,input().split())
graph[c-1].append(d-1)
graph[d-1].append(c-1)
k=int(input())
b=list(map(int,input().split()))
queue=[]
for i in range(n):
queue.append((a[i],i+1))
queue.sort()
ans=[]
lights=[0]*n
for i in range(k):
lights[b[i]-1]=1
for i in range(n):
val,pos=queue[i]
if lights[pos-1]==1:
ans.append(pos)
for j in graph[pos-1]:
if a[j]>val:
lights[j]=1-lights[j]
print(len(ans))
for i in ans:
print(i)
yuusanlondon