結果

問題 No.1477 Lamps on Graph
ユーザー eijiroueijirou
提出日時 2021-04-16 21:12:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 110,364 KB
最終ジャッジ日時 2023-09-15 23:00:41
合計ジャッジ時間 10,038 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,112 KB
testcase_01 AC 73 ms
71,360 KB
testcase_02 AC 72 ms
70,964 KB
testcase_03 AC 70 ms
71,320 KB
testcase_04 AC 72 ms
71,380 KB
testcase_05 AC 72 ms
71,264 KB
testcase_06 AC 71 ms
71,264 KB
testcase_07 AC 71 ms
71,256 KB
testcase_08 AC 73 ms
71,324 KB
testcase_09 AC 72 ms
70,992 KB
testcase_10 AC 72 ms
71,176 KB
testcase_11 AC 72 ms
71,180 KB
testcase_12 AC 210 ms
85,024 KB
testcase_13 AC 205 ms
88,820 KB
testcase_14 AC 227 ms
88,444 KB
testcase_15 AC 146 ms
80,424 KB
testcase_16 AC 148 ms
82,476 KB
testcase_17 AC 147 ms
82,392 KB
testcase_18 AC 242 ms
92,628 KB
testcase_19 AC 201 ms
88,176 KB
testcase_20 AC 136 ms
79,384 KB
testcase_21 AC 217 ms
90,500 KB
testcase_22 AC 122 ms
77,964 KB
testcase_23 AC 159 ms
80,480 KB
testcase_24 AC 250 ms
93,248 KB
testcase_25 AC 149 ms
80,144 KB
testcase_26 AC 252 ms
92,868 KB
testcase_27 AC 163 ms
81,096 KB
testcase_28 AC 190 ms
85,080 KB
testcase_29 AC 171 ms
82,688 KB
testcase_30 AC 164 ms
87,292 KB
testcase_31 AC 158 ms
83,360 KB
testcase_32 AC 298 ms
110,364 KB
testcase_33 AC 284 ms
105,552 KB
testcase_34 AC 173 ms
104,184 KB
testcase_35 AC 325 ms
95,648 KB
testcase_36 AC 332 ms
94,916 KB
testcase_37 AC 296 ms
94,800 KB
testcase_38 AC 305 ms
95,440 KB
testcase_39 AC 310 ms
94,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input = stdin.readline

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    edges = [[] for _ in range(n)]
    for _ in range(m):
        u, v = map(int, input().split())
        if a[u-1] < a[v-1]:
            edges[u-1].append(v-1)
        elif a[u-1] > a[v-1]:
            edges[v-1].append(u-1)
    
    k = int(input())
    switch = [0] * n
    for b in map(int, input().split()):
        switch[b-1] = 1
    
    ans = []
    for u in sorted(range(n), key=lambda x: a[x]):
        if switch[u]:
            #switch[u] = 0
            ans.append(u+1)
            for v in edges[u]:
                switch[v] ^= 1
    
    print(len(ans))
    print(*ans, sep='\n')

main()
0