結果

問題 No.1477 Lamps on Graph
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-16 20:28:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 562 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 114,560 KB
最終ジャッジ日時 2024-07-02 22:47:26
合計ジャッジ時間 12,581 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
e = [[] for i in range(n)]
A = list(map(int,input().split()))
for i in range(m):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    e[u].append(v)
    e[v].append(u)

k = int(input())
B = list(map(int,input().split()))

ans = []
switch = [0]*n
for b in B:
    switch[b-1] = 1
sA = [[A[i],i] for i in range(n)]
sA.sort()
for a,ind in sA:
    if switch[ind] == 0:
        continue
    switch[ind] = 0
    ans.append(ind+1)
    for nex in e[ind]:
        if A[nex] > a:
            switch[nex] = (switch[nex]+1)%2
print(len(ans))
for i in ans:
    print(i)
0