結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-26 17:59:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,303 bytes |
| コンパイル時間 | 81 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 57,108 KB |
| 最終ジャッジ日時 | 2024-07-05 03:28:41 |
| 合計ジャッジ時間 | 19,532 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 TLE * 1 -- * 7 |
ソースコード
class Peek:
def __init__(self, i, A):
self.i = i
self.A = A
self.V = []
self.B = False
def __str__(self):
return str(self.i) + ":" + str(self.A) + "," + str(self.B) + "," + str(self.V)
N, M = map(int, input().split())
A = []
for i, a in enumerate(list(map(int, input().split()))):
A.append(Peek(i, a))
for _ in range(M):
u, v = map(int, input().split())
A[u-1].V.append(v-1)
A[v-1].V.append(u-1)
K = int(input())
for b in list(map(int, input().split())):
A[b-1].B = True
S = []
for P in A:
noInput = True
for i in P.V:
if P.A > A[i].A:
noInput = False
elif P.A == A[i].A:
P.V.remove(i)
if noInput:
S.append(P)
op = []
while len(S) > 0:
n = S.pop(0)
b = n.B
if b:
n.B = False
op.append(n.i + 1)
for i in n.V:
m = A[i]
m.V.remove(n.i)
if b:
m.B = not m.B
noInput = True
for i in m.V:
if m.A > A[i].A:
noInput = False
elif m.A == A[i].A:
m.V.remove(i)
if noInput:
S.append(m)
if any([i.B for i in A]):
print(-1)
else:
print(len(op))
for p in op:
print(p)