結果

問題 No.1477 Lamps on Graph
ユーザー zkouzkou
提出日時 2021-04-16 20:13:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 477 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 1,233 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 113,176 KB
最終ジャッジ日時 2023-09-15 20:32:18
合計ジャッジ時間 14,031 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,268 KB
testcase_01 AC 81 ms
71,564 KB
testcase_02 AC 79 ms
71,316 KB
testcase_03 AC 80 ms
71,180 KB
testcase_04 AC 81 ms
71,316 KB
testcase_05 AC 80 ms
71,064 KB
testcase_06 AC 79 ms
71,192 KB
testcase_07 AC 79 ms
71,440 KB
testcase_08 AC 79 ms
71,432 KB
testcase_09 AC 77 ms
71,404 KB
testcase_10 AC 79 ms
71,424 KB
testcase_11 AC 80 ms
71,352 KB
testcase_12 AC 299 ms
89,288 KB
testcase_13 AC 279 ms
93,796 KB
testcase_14 AC 324 ms
94,296 KB
testcase_15 AC 209 ms
82,368 KB
testcase_16 AC 196 ms
85,072 KB
testcase_17 AC 198 ms
84,588 KB
testcase_18 AC 317 ms
106,168 KB
testcase_19 AC 270 ms
91,548 KB
testcase_20 AC 177 ms
79,532 KB
testcase_21 AC 286 ms
97,036 KB
testcase_22 AC 155 ms
79,244 KB
testcase_23 AC 233 ms
83,656 KB
testcase_24 AC 373 ms
100,836 KB
testcase_25 AC 195 ms
81,616 KB
testcase_26 AC 336 ms
97,904 KB
testcase_27 AC 222 ms
84,368 KB
testcase_28 AC 254 ms
87,648 KB
testcase_29 AC 232 ms
84,840 KB
testcase_30 AC 198 ms
92,556 KB
testcase_31 AC 197 ms
85,248 KB
testcase_32 AC 412 ms
112,748 KB
testcase_33 AC 396 ms
112,452 KB
testcase_34 AC 263 ms
113,176 KB
testcase_35 AC 477 ms
105,716 KB
testcase_36 AC 465 ms
105,380 KB
testcase_37 AC 434 ms
103,472 KB
testcase_38 AC 446 ms
104,076 KB
testcase_39 AC 461 ms
105,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
As = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)
K = int(input())
on = [False] * N
for B in map(int, input().split()):
    B -= 1
    on[B] = True

iAs = sorted(enumerate(As), key=lambda t: t[1])

answer = []
for i, A in iAs:
    if on[i] == True:
        answer.append(i)
        for nv in adj[i]:
            if As[nv] > As[i]:
                on[nv] = not on[nv]

print(len(answer))
print(*[a + 1 for a in answer], sep='\n')
0