結果

問題 No.1477 Lamps on Graph
ユーザー 👑 tamatotamato
提出日時 2021-04-16 20:10:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 121,604 KB
最終ジャッジ日時 2023-09-15 20:23:38
合計ジャッジ時間 11,144 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,560 KB
testcase_01 AC 74 ms
71,736 KB
testcase_02 AC 74 ms
71,540 KB
testcase_03 AC 76 ms
71,552 KB
testcase_04 AC 78 ms
71,828 KB
testcase_05 AC 75 ms
71,636 KB
testcase_06 AC 74 ms
71,552 KB
testcase_07 AC 75 ms
71,736 KB
testcase_08 AC 75 ms
71,664 KB
testcase_09 AC 75 ms
71,660 KB
testcase_10 AC 76 ms
71,696 KB
testcase_11 AC 78 ms
71,640 KB
testcase_12 AC 240 ms
88,428 KB
testcase_13 AC 233 ms
92,116 KB
testcase_14 AC 257 ms
93,612 KB
testcase_15 AC 165 ms
82,212 KB
testcase_16 AC 160 ms
83,668 KB
testcase_17 AC 161 ms
83,828 KB
testcase_18 AC 270 ms
102,520 KB
testcase_19 AC 219 ms
91,952 KB
testcase_20 AC 138 ms
79,668 KB
testcase_21 AC 241 ms
100,092 KB
testcase_22 AC 122 ms
78,784 KB
testcase_23 AC 172 ms
82,704 KB
testcase_24 AC 285 ms
103,112 KB
testcase_25 AC 157 ms
81,816 KB
testcase_26 AC 294 ms
98,232 KB
testcase_27 AC 179 ms
83,992 KB
testcase_28 AC 205 ms
88,092 KB
testcase_29 AC 185 ms
85,264 KB
testcase_30 AC 168 ms
89,460 KB
testcase_31 AC 173 ms
86,784 KB
testcase_32 AC 328 ms
121,604 KB
testcase_33 AC 315 ms
117,824 KB
testcase_34 AC 194 ms
114,200 KB
testcase_35 AC 356 ms
108,436 KB
testcase_36 AC 362 ms
106,424 KB
testcase_37 AC 336 ms
100,280 KB
testcase_38 AC 347 ms
102,220 KB
testcase_39 AC 353 ms
106,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)
    K = int(input())
    B = list(map(int, input().split()))

    AI = [(a, i+1) for i, a in enumerate(A)]
    AI.sort(key=lambda x: x[0])
    on = [0] * (N+1)
    for b in B:
        on[b] = 1
    ans = []
    for a, i in AI:
        if on[i]:
            ans.append(i)
            on[i] = 0
            for j in adj[i]:
                if A[i-1] < A[j-1]:
                    on[j] ^= 1
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
0