結果

問題 No.1477 Lamps on Graph
ユーザー lie_of_lillielie_of_lillie
提出日時 2021-05-12 20:11:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 718 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 81,556 KB
実行使用メモリ 95,428 KB
最終ジャッジ日時 2023-10-24 14:28:33
合計ジャッジ時間 11,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
60,000 KB
testcase_01 AC 40 ms
55,432 KB
testcase_02 AC 39 ms
55,432 KB
testcase_03 AC 41 ms
55,432 KB
testcase_04 AC 40 ms
55,432 KB
testcase_05 AC 42 ms
55,432 KB
testcase_06 AC 41 ms
55,432 KB
testcase_07 AC 40 ms
55,432 KB
testcase_08 AC 40 ms
55,432 KB
testcase_09 AC 41 ms
55,432 KB
testcase_10 AC 41 ms
55,432 KB
testcase_11 AC 40 ms
55,432 KB
testcase_12 AC 1,018 ms
90,468 KB
testcase_13 AC 1,492 ms
91,656 KB
testcase_14 AC 1,489 ms
93,156 KB
testcase_15 AC 215 ms
82,036 KB
testcase_16 AC 379 ms
83,088 KB
testcase_17 AC 477 ms
82,752 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #




import collections

N, M = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

G = collections.defaultdict(list)

for _ in range(M):
    v0, v1 = map(lambda x: int(x) - 1, input().split())
    G[v0].append(v1)
    G[v1].append(v0)

K = int(input())
B = list(map(lambda x: int(x) - 1, input().split()))

onoff = [int(gi in B) for gi in range(N)]
greedy = [(A[ai], ai) for ai in range(N)]
greedy.sort()

ans = []
for a, gi in greedy:
    if onoff[gi] != 1:
        continue
    onoff[gi] = 0
    ans.append(gi)
    for ri in G[gi]:
        if A[ri] > a:
            onoff[ri] ^= 1

if sum(onoff) > 0:
    print(-1)
else:
    print(len(ans))
    print(*map(lambda x: x + 1, ans), sep='\n')
0