結果

問題 No.1477 Lamps on Graph
ユーザー nasubi24nasubi24
提出日時 2021-04-16 20:18:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 111,704 KB
最終ジャッジ日時 2023-09-15 20:43:47
合計ジャッジ時間 11,389 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,288 KB
testcase_01 AC 70 ms
71,336 KB
testcase_02 AC 69 ms
71,284 KB
testcase_03 AC 70 ms
71,252 KB
testcase_04 AC 68 ms
70,996 KB
testcase_05 AC 71 ms
71,236 KB
testcase_06 AC 69 ms
71,140 KB
testcase_07 AC 70 ms
71,224 KB
testcase_08 AC 70 ms
71,144 KB
testcase_09 AC 69 ms
71,264 KB
testcase_10 AC 70 ms
71,144 KB
testcase_11 AC 70 ms
71,172 KB
testcase_12 AC 269 ms
91,220 KB
testcase_13 AC 250 ms
93,444 KB
testcase_14 AC 283 ms
92,296 KB
testcase_15 AC 193 ms
83,316 KB
testcase_16 AC 182 ms
85,396 KB
testcase_17 AC 179 ms
84,556 KB
testcase_18 AC 296 ms
104,248 KB
testcase_19 AC 247 ms
91,240 KB
testcase_20 AC 160 ms
79,548 KB
testcase_21 AC 256 ms
94,432 KB
testcase_22 AC 145 ms
78,808 KB
testcase_23 AC 204 ms
83,888 KB
testcase_24 AC 316 ms
101,368 KB
testcase_25 AC 181 ms
81,308 KB
testcase_26 AC 314 ms
99,496 KB
testcase_27 AC 199 ms
82,520 KB
testcase_28 AC 221 ms
85,168 KB
testcase_29 AC 225 ms
85,796 KB
testcase_30 AC 194 ms
92,480 KB
testcase_31 AC 186 ms
85,588 KB
testcase_32 AC 377 ms
111,704 KB
testcase_33 AC 365 ms
111,004 KB
testcase_34 AC 219 ms
106,424 KB
testcase_35 AC 383 ms
104,196 KB
testcase_36 AC 382 ms
102,360 KB
testcase_37 AC 358 ms
99,000 KB
testcase_38 AC 378 ms
101,604 KB
testcase_39 AC 388 ms
102,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
a=list(map(int,input().split()))
path=[[] for _ in range(n)]
for i in range(m):
    c,d=map(int,input().split())
    if a[c-1]<a[d-1]:path[c-1].append(d-1)
    if a[d-1]<a[c-1]:path[d-1].append(c-1)
seen=[False]*n
k=int(input())
b=list(map(int,input().split()))
for i in b:seen[i-1]=True
num=[[a[_],_] for _ in range(n)]
num.sort(key=lambda x: x[0])
ans=[]
for i in range(n):
    ind=num[i][1]
    if seen[ind]:
        ans.append(ind+1)
        for j in range(len(path[ind])):
            if seen[path[ind][j]]:seen[path[ind][j]]=False
            else:seen[path[ind][j]]=True
print(len(ans))
for i in ans:print(i)
0