結果
問題 | No.1477 Lamps on Graph |
ユーザー |
![]() |
提出日時 | 2021-05-03 19:48:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 667 ms / 2,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 753 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 157,384 KB |
最終ジャッジ日時 | 2024-07-22 10:12:40 |
合計ジャッジ時間 | 15,667 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
from collections import defaultdictN, M = map(int, input().split())A = [0]+list(map(int, input().split()))task = [[0, 0]]+[[A[i], i] for i in range(1, N+1)]task.sort()Edges = defaultdict(set)for _ in range(M):u, v = map(int, input().split())Edges[u].add(v)Edges[v].add(u)K = int(input())B = set(map(int, input().split()))state = [int(i in B) for i in range(N+1)]ans = []for a, v in task:if not state[v]:continuestate[v] = 0ans.append(v)for e in Edges[v]:if A[e] > a:state[e] ^= 1if sum(state):print(-1)else:print(len(ans))print(*ans, sep='\n')