結果

問題 No.1477 Lamps on Graph
ユーザー 👑 terry_u16terry_u16
提出日時 2021-04-16 20:47:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 115,624 KB
最終ジャッジ日時 2023-09-15 21:56:50
合計ジャッジ時間 13,664 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,344 KB
testcase_01 AC 73 ms
71,224 KB
testcase_02 AC 75 ms
71,280 KB
testcase_03 AC 73 ms
71,260 KB
testcase_04 AC 72 ms
71,064 KB
testcase_05 AC 72 ms
71,300 KB
testcase_06 AC 72 ms
71,272 KB
testcase_07 AC 70 ms
71,280 KB
testcase_08 AC 72 ms
71,360 KB
testcase_09 AC 73 ms
71,380 KB
testcase_10 AC 73 ms
71,464 KB
testcase_11 AC 72 ms
71,192 KB
testcase_12 AC 318 ms
89,316 KB
testcase_13 AC 309 ms
93,116 KB
testcase_14 AC 363 ms
92,828 KB
testcase_15 AC 209 ms
82,196 KB
testcase_16 AC 220 ms
84,352 KB
testcase_17 AC 218 ms
84,396 KB
testcase_18 AC 403 ms
102,548 KB
testcase_19 AC 322 ms
92,392 KB
testcase_20 AC 181 ms
80,448 KB
testcase_21 AC 347 ms
93,060 KB
testcase_22 AC 153 ms
79,260 KB
testcase_23 AC 250 ms
83,508 KB
testcase_24 AC 419 ms
100,624 KB
testcase_25 AC 203 ms
81,680 KB
testcase_26 AC 424 ms
100,444 KB
testcase_27 AC 232 ms
84,912 KB
testcase_28 AC 292 ms
88,316 KB
testcase_29 AC 266 ms
86,528 KB
testcase_30 AC 240 ms
90,032 KB
testcase_31 AC 227 ms
85,888 KB
testcase_32 AC 489 ms
115,376 KB
testcase_33 AC 480 ms
115,236 KB
testcase_34 AC 252 ms
115,624 KB
testcase_35 AC 538 ms
108,608 KB
testcase_36 AC 553 ms
106,348 KB
testcase_37 AC 504 ms
99,832 KB
testcase_38 AC 520 ms
101,636 KB
testcase_39 AC 526 ms
106,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(n, m) = map(int, input().split())
a = list(map(int, input().split()))
graph = [[] for _ in range(n)]

for _ in range(m):
    (u, v) = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

_ = input()
b = list(map(int, input().split()))
on = [False] * n

for bi in b:
    on[bi - 1] = True

indice = [(ai, index) for ai, index in zip(a, range(n))]
indice.sort()

results = []

for (ai, index) in indice:
    if on[index]:
        on[index] = False
        results.append(index + 1)
        for v in graph[index]:
            if a[index] < a[v]:
                on[v] ^= True

if any(on):
    print(-1)
else:
    print(len(results))
    for res in results:
        print(res)
0