結果

問題 No.1477 Lamps on Graph
ユーザー convexineqconvexineq
提出日時 2021-04-16 20:14:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 427 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 108,476 KB
最終ジャッジ日時 2023-09-15 20:34:52
合計ジャッジ時間 11,777 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,588 KB
testcase_01 AC 79 ms
71,304 KB
testcase_02 AC 76 ms
71,048 KB
testcase_03 AC 80 ms
71,540 KB
testcase_04 AC 77 ms
71,496 KB
testcase_05 AC 77 ms
71,304 KB
testcase_06 AC 79 ms
71,396 KB
testcase_07 AC 79 ms
71,268 KB
testcase_08 AC 76 ms
71,068 KB
testcase_09 AC 78 ms
71,416 KB
testcase_10 AC 77 ms
71,512 KB
testcase_11 AC 77 ms
71,116 KB
testcase_12 AC 268 ms
86,548 KB
testcase_13 AC 262 ms
89,808 KB
testcase_14 AC 304 ms
88,864 KB
testcase_15 AC 193 ms
82,068 KB
testcase_16 AC 182 ms
84,508 KB
testcase_17 AC 178 ms
84,080 KB
testcase_18 AC 288 ms
100,700 KB
testcase_19 AC 249 ms
88,592 KB
testcase_20 AC 167 ms
79,360 KB
testcase_21 AC 256 ms
92,052 KB
testcase_22 AC 153 ms
78,704 KB
testcase_23 AC 219 ms
82,124 KB
testcase_24 AC 331 ms
94,428 KB
testcase_25 AC 192 ms
81,256 KB
testcase_26 AC 308 ms
95,364 KB
testcase_27 AC 209 ms
83,116 KB
testcase_28 AC 235 ms
86,148 KB
testcase_29 AC 222 ms
83,676 KB
testcase_30 AC 193 ms
89,728 KB
testcase_31 AC 185 ms
85,120 KB
testcase_32 AC 371 ms
108,476 KB
testcase_33 AC 339 ms
99,656 KB
testcase_34 AC 225 ms
104,076 KB
testcase_35 AC 427 ms
101,400 KB
testcase_36 AC 390 ms
97,464 KB
testcase_37 AC 367 ms
97,292 KB
testcase_38 AC 376 ms
97,344 KB
testcase_39 AC 392 ms
97,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
*a, = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    if a[u] < a[v]:
        g[u].append(v)
    if a[v] < a[u]:
        g[v].append(u)
res = [0]*n
_ = input()
for i in map(int,input().split()):
    res[i-1] = 1
ans = []
for v in sorted(range(n), key=lambda i:a[i]):
    if res[v]:
        res[v] = 0
        ans.append(v+1)
        for c in g[v]:
            res[c] ^= 1
if sum(res):
    print(-1)
else:
    print(len(ans))
    print(*ans,sep="\n")
0