結果

問題 No.1477 Lamps on Graph
ユーザー trineutrontrineutron
提出日時 2021-04-16 20:14:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 678 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 39,368 KB
最終ジャッジ日時 2023-09-15 20:35:22
合計ジャッジ時間 14,570 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,760 KB
testcase_01 AC 15 ms
7,928 KB
testcase_02 AC 16 ms
7,740 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 15 ms
7,808 KB
testcase_05 AC 15 ms
7,812 KB
testcase_06 AC 16 ms
7,936 KB
testcase_07 AC 15 ms
7,844 KB
testcase_08 AC 15 ms
7,828 KB
testcase_09 AC 16 ms
7,812 KB
testcase_10 AC 16 ms
7,924 KB
testcase_11 AC 15 ms
7,896 KB
testcase_12 AC 414 ms
23,444 KB
testcase_13 AC 355 ms
23,444 KB
testcase_14 AC 499 ms
25,588 KB
testcase_15 AC 242 ms
14,660 KB
testcase_16 AC 126 ms
17,168 KB
testcase_17 AC 116 ms
16,760 KB
testcase_18 AC 332 ms
33,340 KB
testcase_19 AC 314 ms
25,060 KB
testcase_20 AC 153 ms
12,996 KB
testcase_21 AC 294 ms
29,280 KB
testcase_22 AC 131 ms
10,536 KB
testcase_23 AC 328 ms
15,948 KB
testcase_24 AC 559 ms
30,196 KB
testcase_25 AC 214 ms
14,368 KB
testcase_26 AC 467 ms
32,084 KB
testcase_27 AC 271 ms
16,908 KB
testcase_28 AC 305 ms
21,992 KB
testcase_29 AC 291 ms
18,856 KB
testcase_30 AC 157 ms
21,548 KB
testcase_31 AC 129 ms
17,892 KB
testcase_32 AC 653 ms
38,332 KB
testcase_33 AC 625 ms
38,620 KB
testcase_34 AC 499 ms
34,968 KB
testcase_35 AC 678 ms
39,368 KB
testcase_36 AC 678 ms
39,080 KB
testcase_37 AC 619 ms
37,252 KB
testcase_38 AC 646 ms
37,536 KB
testcase_39 AC 675 ms
38,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = list(map(int, input().split()))
to = [[] for _ in range(n)]
for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    if a[u] < a[v]:
        to[u].append(v)
    if a[v] < a[u]:
        to[v].append(u)
k = int(input())
on = [False] * n
b = list(map(int, input().split()))
for i in b:
    on[i - 1] = True
a_sorted = sorted([(a[i], i) for i in range(n)])
ans = []
for _, i in a_sorted:
    if on[i]:
        ans.append(i)
        for j in to[i]:
            on[j] = not on[j]
print(len(ans))
for x in ans:
    print(x + 1)
0