結果

問題 No.1477 Lamps on Graph
ユーザー toyuzukotoyuzuko
提出日時 2021-04-17 17:13:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 123,544 KB
最終ジャッジ日時 2023-09-17 02:38:47
合計ジャッジ時間 9,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,832 KB
testcase_01 AC 77 ms
71,752 KB
testcase_02 AC 76 ms
71,620 KB
testcase_03 AC 74 ms
71,748 KB
testcase_04 AC 79 ms
71,456 KB
testcase_05 AC 75 ms
71,572 KB
testcase_06 AC 75 ms
71,692 KB
testcase_07 AC 76 ms
71,704 KB
testcase_08 AC 74 ms
71,844 KB
testcase_09 AC 73 ms
71,408 KB
testcase_10 AC 75 ms
71,700 KB
testcase_11 AC 74 ms
71,732 KB
testcase_12 AC 173 ms
89,344 KB
testcase_13 AC 168 ms
92,752 KB
testcase_14 AC 186 ms
90,616 KB
testcase_15 AC 126 ms
81,960 KB
testcase_16 AC 134 ms
86,264 KB
testcase_17 AC 132 ms
85,712 KB
testcase_18 AC 224 ms
109,500 KB
testcase_19 AC 176 ms
92,516 KB
testcase_20 AC 115 ms
80,464 KB
testcase_21 AC 194 ms
101,328 KB
testcase_22 AC 114 ms
78,244 KB
testcase_23 AC 130 ms
82,128 KB
testcase_24 AC 202 ms
97,968 KB
testcase_25 AC 122 ms
81,392 KB
testcase_26 AC 208 ms
100,952 KB
testcase_27 AC 135 ms
83,508 KB
testcase_28 AC 153 ms
89,200 KB
testcase_29 AC 150 ms
84,836 KB
testcase_30 AC 156 ms
95,760 KB
testcase_31 AC 139 ms
87,812 KB
testcase_32 AC 253 ms
123,544 KB
testcase_33 AC 250 ms
120,332 KB
testcase_34 AC 154 ms
104,436 KB
testcase_35 AC 279 ms
112,444 KB
testcase_36 AC 273 ms
110,544 KB
testcase_37 AC 256 ms
101,740 KB
testcase_38 AC 262 ms
104,500 KB
testcase_39 AC 267 ms
110,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

from collections import deque

N, M = map(int, input().split())

A = list(map(int, input().split()))

g = [[] for _ in range(N)]
deg = [0] * N

for _ in range(M):
    u, v = map(int, input().split())
    u -= 1; v -= 1
    if A[u] < A[v]:
        g[u].append(v)
        deg[v] += 1
    elif A[u] > A[v]:
        g[v].append(u)
        deg[u] += 1

tps = sorted(range(N), key=lambda x: A[x])

K = int(input())
B = list(map(int, input().split()))

C = [0] * N

for b in B:
    C[b - 1] = 1

res = []

for v in tps:
    if C[v] == 1:
        for adj in g[v]:
            C[adj] ^= 1
        res.append(v + 1)

print(len(res))
print('\n'.join(map(str, res)))
0