結果
| 問題 | No.1477 Lamps on Graph |
| コンテスト | |
| ユーザー |
taiga000629
|
| 提出日時 | 2021-04-16 22:23:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 732 bytes |
| 記録 | |
| コンパイル時間 | 195 ms |
| コンパイル使用メモリ | 82,428 KB |
| 実行使用メモリ | 98,796 KB |
| 最終ジャッジ日時 | 2024-07-03 02:23:13 |
| 合計ジャッジ時間 | 9,167 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 TLE * 1 -- * 17 |
ソースコード
n,m=map(int,input().split())
a=[-1]+list(map(int,input().split()))
root=[[] for i in range(n+1)]
rootr=[[] for i in range(n+1)]
import sys
sys.setrecursionlimit(10**9)
for i in range(m):
v,u=map(int,input().split())
if a[v]>a[u]:
root[u].append(v)
rootr[v].append(u)
elif a[u]>a[v]:
root[v].append(u)
rootr[u].append(v)
memo=[-1]*(n+1)
light=[0]*(n+1)
ans=[]
k=int(input())
b=list(map(int,input().split()))
for x in b:light[x]=1
def ch(x):
light[x]^=1
ans.append(x)
for nod in root[x]:
light[nod]^=1
def f(x):
if memo[x]==1:pass
for nod in rootr[x]:f(nod)
if light[x]==1:ch(x)
memo[x]=1
for i in range(1,n+1):f(i)
print(len(ans))
for x in ans:print(x)
taiga000629