結果

問題 No.1477 Lamps on Graph
ユーザー 👑 H20H20
提出日時 2021-04-21 13:11:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 122,304 KB
最終ジャッジ日時 2023-09-17 09:30:06
合計ジャッジ時間 12,176 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,028 KB
testcase_01 AC 70 ms
71,084 KB
testcase_02 AC 71 ms
71,128 KB
testcase_03 AC 71 ms
71,100 KB
testcase_04 AC 72 ms
70,968 KB
testcase_05 AC 72 ms
70,804 KB
testcase_06 AC 71 ms
70,812 KB
testcase_07 AC 72 ms
70,820 KB
testcase_08 AC 72 ms
70,948 KB
testcase_09 AC 72 ms
71,236 KB
testcase_10 AC 71 ms
70,968 KB
testcase_11 AC 73 ms
70,796 KB
testcase_12 AC 280 ms
89,800 KB
testcase_13 AC 277 ms
94,104 KB
testcase_14 AC 315 ms
95,368 KB
testcase_15 AC 198 ms
83,132 KB
testcase_16 AC 190 ms
87,032 KB
testcase_17 AC 190 ms
86,404 KB
testcase_18 AC 324 ms
103,996 KB
testcase_19 AC 281 ms
96,260 KB
testcase_20 AC 167 ms
80,784 KB
testcase_21 AC 273 ms
103,484 KB
testcase_22 AC 150 ms
79,204 KB
testcase_23 AC 216 ms
84,200 KB
testcase_24 AC 362 ms
102,760 KB
testcase_25 AC 189 ms
82,384 KB
testcase_26 AC 349 ms
100,780 KB
testcase_27 AC 209 ms
84,384 KB
testcase_28 AC 244 ms
88,132 KB
testcase_29 AC 225 ms
86,364 KB
testcase_30 AC 200 ms
94,232 KB
testcase_31 AC 198 ms
88,192 KB
testcase_32 AC 385 ms
121,856 KB
testcase_33 AC 375 ms
119,452 KB
testcase_34 AC 257 ms
122,304 KB
testcase_35 AC 449 ms
112,380 KB
testcase_36 AC 459 ms
110,332 KB
testcase_37 AC 409 ms
101,348 KB
testcase_38 AC 425 ms
104,108 KB
testcase_39 AC 444 ms
110,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]:
            if A[i]<A[l]:
                LAMP[l]=not LAMP[l]
print(len(ANS))
for ans in ANS:
    print(ans)


0