結果

問題 No.1477 Lamps on Graph
コンテスト
ユーザー H20
提出日時 2021-04-21 13:10:36
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 607 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 207 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 121,676 KB
最終ジャッジ日時 2026-03-25 14:04:14
合計ジャッジ時間 12,022 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 1
other AC * 1 RE * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M=map(int,input().split())
A=[-1]+list(map(int,input().split()))
AS= [[0] * 2 for i in range(N+1)]
for i,a in enumerate(A):
    AS[i][0]=i
    AS[i][1]=a

AS = sorted(AS, key=lambda x: x[1])

L = []
for i in range(N+1):
    L.append([])
for i in range(M):
    v,u = map(int,input().split())
    L[v].append(u)
    L[u].append(v)
K = int(input())
B=list(map(int,input().split()))
LAMP=[False]*(N+1)
for b in B:
    LAMP[b]=True
ANS = []
for i,a in AS:
    if LAMP[i]:
        ANS.append(i)
        for l in L[i] and A[i]<A[l]:
            LAMP[l]=not LAMP[l]
print(len(ANS))
for ans in ANS:
    print(ans)
0