結果

問題 No.1477 Lamps on Graph
ユーザー gorugo30gorugo30
提出日時 2021-05-08 16:50:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 454 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 113,392 KB
最終ジャッジ日時 2023-10-15 04:22:24
合計ジャッジ時間 15,911 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
70,928 KB
testcase_01 AC 76 ms
71,096 KB
testcase_02 AC 75 ms
71,204 KB
testcase_03 AC 77 ms
71,148 KB
testcase_04 AC 77 ms
71,208 KB
testcase_05 AC 76 ms
71,356 KB
testcase_06 AC 76 ms
71,300 KB
testcase_07 AC 77 ms
71,088 KB
testcase_08 AC 78 ms
71,304 KB
testcase_09 AC 76 ms
71,212 KB
testcase_10 AC 78 ms
71,292 KB
testcase_11 AC 76 ms
71,168 KB
testcase_12 AC 323 ms
86,492 KB
testcase_13 AC 269 ms
91,180 KB
testcase_14 AC 310 ms
90,188 KB
testcase_15 AC 202 ms
82,932 KB
testcase_16 AC 186 ms
83,892 KB
testcase_17 AC 182 ms
83,932 KB
testcase_18 AC 325 ms
108,388 KB
testcase_19 AC 258 ms
89,116 KB
testcase_20 AC 170 ms
80,460 KB
testcase_21 AC 261 ms
98,712 KB
testcase_22 AC 153 ms
78,976 KB
testcase_23 AC 224 ms
83,888 KB
testcase_24 AC 350 ms
98,464 KB
testcase_25 AC 190 ms
81,660 KB
testcase_26 AC 320 ms
94,248 KB
testcase_27 AC 213 ms
83,604 KB
testcase_28 AC 242 ms
86,040 KB
testcase_29 AC 225 ms
83,896 KB
testcase_30 AC 189 ms
89,732 KB
testcase_31 AC 190 ms
84,832 KB
testcase_32 AC 373 ms
113,392 KB
testcase_33 AC 370 ms
112,784 KB
testcase_34 AC 251 ms
113,340 KB
testcase_35 AC 454 ms
110,164 KB
testcase_36 AC 452 ms
106,972 KB
testcase_37 AC 417 ms
98,684 KB
testcase_38 AC 417 ms
100,072 KB
testcase_39 AC 435 ms
106,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
L = [0] * N
A = list(map(int, input().split()))
V = [i for i in range(N)]
V.sort(key = lambda x: A[x])
adj = [[] for i in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)
K = int(input())
B = list(map(int, input().split()))
for b in B:
    L[b - 1] = 1

op = []
for v in V:
    if L[v] == 0:
        continue
    L[v] = 0
    op.append(v + 1)
    for nv in adj[v]:
        if A[nv] > A[v]:
            L[nv] ^= 1


if sum(L) != 0:
    print(-1)
else:
    print(len(op))
    print(*op, sep = "\n")
0