結果

問題 No.1477 Lamps on Graph
ユーザー yuusanlondonyuusanlondon
提出日時 2021-04-16 20:24:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 116,208 KB
最終ジャッジ日時 2023-09-15 21:05:24
合計ジャッジ時間 13,637 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,092 KB
testcase_01 AC 76 ms
71,600 KB
testcase_02 AC 76 ms
71,516 KB
testcase_03 AC 76 ms
71,268 KB
testcase_04 AC 77 ms
71,496 KB
testcase_05 AC 76 ms
71,244 KB
testcase_06 AC 75 ms
71,416 KB
testcase_07 AC 76 ms
71,464 KB
testcase_08 AC 75 ms
71,424 KB
testcase_09 AC 76 ms
71,392 KB
testcase_10 AC 76 ms
71,512 KB
testcase_11 AC 75 ms
71,388 KB
testcase_12 AC 270 ms
90,060 KB
testcase_13 AC 268 ms
92,928 KB
testcase_14 AC 289 ms
92,580 KB
testcase_15 AC 168 ms
82,620 KB
testcase_16 AC 192 ms
84,804 KB
testcase_17 AC 189 ms
84,988 KB
testcase_18 AC 368 ms
102,820 KB
testcase_19 AC 283 ms
92,772 KB
testcase_20 AC 148 ms
80,592 KB
testcase_21 AC 322 ms
99,036 KB
testcase_22 AC 122 ms
79,112 KB
testcase_23 AC 183 ms
83,616 KB
testcase_24 AC 344 ms
100,640 KB
testcase_25 AC 164 ms
82,328 KB
testcase_26 AC 371 ms
98,488 KB
testcase_27 AC 194 ms
84,484 KB
testcase_28 AC 248 ms
89,524 KB
testcase_29 AC 214 ms
85,420 KB
testcase_30 AC 225 ms
90,364 KB
testcase_31 AC 206 ms
85,804 KB
testcase_32 AC 425 ms
116,208 KB
testcase_33 AC 412 ms
115,964 KB
testcase_34 AC 201 ms
115,992 KB
testcase_35 AC 453 ms
109,724 KB
testcase_36 AC 458 ms
107,504 KB
testcase_37 AC 427 ms
105,108 KB
testcase_38 AC 442 ms
104,860 KB
testcase_39 AC 454 ms
107,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import os,io,heapq
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
graph=[]
for i in range(n):
  graph.append([])
for i in range(m):
  c,d=map(int,input().split())
  graph[c-1].append(d-1)
  graph[d-1].append(c-1)
k=int(input())
b=list(map(int,input().split()))
queue=[]
for i in range(n):
  queue.append((a[i],i+1))
queue.sort()
ans=[]
lights=[0]*n
for i in range(k):
  lights[b[i]-1]=1
for i in range(n):
  val,pos=queue[i]
  if lights[pos-1]==1:
    ans.append(pos)
    for j in graph[pos-1]:
      if a[j]>val:
        lights[j]=1-lights[j]
print(len(ans))
for i in ans:
  print(i)
0