結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
gr1msl3y
|
| 提出日時 | 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 defaultdict
N, 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]:
continue
state[v] = 0
ans.append(v)
for e in Edges[v]:
if A[e] > a:
state[e] ^= 1
if sum(state):
print(-1)
else:
print(len(ans))
print(*ans, sep='\n')
gr1msl3y