結果
問題 | No.1477 Lamps on Graph |
ユーザー | yuusanlondon |
提出日時 | 2021-04-16 20:24:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 563 ms / 2,000 ms |
コード長 | 657 bytes |
コンパイル時間 | 335 ms |
コンパイル使用メモリ | 82,332 KB |
実行使用メモリ | 114,252 KB |
最終ジャッジ日時 | 2024-07-02 22:34:44 |
合計ジャッジ時間 | 11,853 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)