結果

問題 No.1477 Lamps on Graph
ユーザー KudeKude
提出日時 2021-04-16 20:10:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 412 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 104,048 KB
最終ジャッジ日時 2023-09-15 20:24:49
合計ジャッジ時間 11,979 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,072 KB
testcase_01 AC 72 ms
70,916 KB
testcase_02 AC 72 ms
71,084 KB
testcase_03 AC 71 ms
70,920 KB
testcase_04 AC 71 ms
71,244 KB
testcase_05 AC 70 ms
70,944 KB
testcase_06 AC 72 ms
70,976 KB
testcase_07 AC 70 ms
71,088 KB
testcase_08 AC 71 ms
71,276 KB
testcase_09 AC 72 ms
71,116 KB
testcase_10 AC 73 ms
70,740 KB
testcase_11 AC 73 ms
71,092 KB
testcase_12 AC 255 ms
86,800 KB
testcase_13 AC 254 ms
90,844 KB
testcase_14 AC 273 ms
91,028 KB
testcase_15 AC 177 ms
81,556 KB
testcase_16 AC 173 ms
83,304 KB
testcase_17 AC 176 ms
82,964 KB
testcase_18 AC 278 ms
99,900 KB
testcase_19 AC 236 ms
88,036 KB
testcase_20 AC 158 ms
79,448 KB
testcase_21 AC 254 ms
94,276 KB
testcase_22 AC 144 ms
78,940 KB
testcase_23 AC 203 ms
83,008 KB
testcase_24 AC 309 ms
96,384 KB
testcase_25 AC 179 ms
80,940 KB
testcase_26 AC 307 ms
93,016 KB
testcase_27 AC 200 ms
83,836 KB
testcase_28 AC 224 ms
86,408 KB
testcase_29 AC 209 ms
83,964 KB
testcase_30 AC 183 ms
89,444 KB
testcase_31 AC 177 ms
83,768 KB
testcase_32 AC 347 ms
104,048 KB
testcase_33 AC 326 ms
103,136 KB
testcase_34 AC 229 ms
103,624 KB
testcase_35 AC 403 ms
102,992 KB
testcase_36 AC 412 ms
103,700 KB
testcase_37 AC 352 ms
94,712 KB
testcase_38 AC 363 ms
95,040 KB
testcase_39 AC 410 ms
102,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = list(map(int, input().split()))
to = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)
s = [False] * n
k = int(input())
for bi in map(int, input().split()):
    bi -= 1
    s[bi] = True

ans = []
for u in sorted(range(n), key=lambda i: a[i]):
    if s[u]:
        s[u] = False
        ans.append(u + 1)
        for v in to[u]:
            if a[u] < a[v]:
                s[v] = not s[v]
if any(s):
    print(-1)
else:
    print(len(ans))
    print(*ans, sep='\n')
0