結果

問題 No.1477 Lamps on Graph
ユーザー 👑 rin204
提出日時 2022-01-18 03:58:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 545 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 119,280 KB
最終ジャッジ日時 2024-11-23 13:13:49
合計ジャッジ時間 14,658 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = list(map(int, input().split()))
C = [(a, i) for i, a in enumerate(A)]
C.sort()
edges = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append(v)
    edges[v].append(u)
k = int(input())
B = list(map(int, input().split()))
on = [True] * n
for b in B: on[b - 1] = False
ans = []
for a, i in C:
    if on[i]:
        continue
    ans.append(i + 1)
    on[i] ^= True
    for j in edges[i]:
        if a < A[j]:
            on[j] ^= True
            
assert all(o for o in on)

print(len(ans))
print(*ans, sep="\n")
0