結果
問題 | No.1477 Lamps on Graph |
ユーザー |
![]() |
提出日時 | 2021-04-16 20:47:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 448 ms / 2,000 ms |
コード長 | 715 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 114,540 KB |
最終ジャッジ日時 | 2024-07-02 23:22:02 |
合計ジャッジ時間 | 10,523 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
(n, m) = map(int, input().split()) a = list(map(int, input().split())) graph = [[] for _ in range(n)] for _ in range(m): (u, v) = map(int, input().split()) u -= 1 v -= 1 graph[u].append(v) graph[v].append(u) _ = input() b = list(map(int, input().split())) on = [False] * n for bi in b: on[bi - 1] = True indice = [(ai, index) for ai, index in zip(a, range(n))] indice.sort() results = [] for (ai, index) in indice: if on[index]: on[index] = False results.append(index + 1) for v in graph[index]: if a[index] < a[v]: on[v] ^= True if any(on): print(-1) else: print(len(results)) for res in results: print(res)