結果

問題 No.1477 Lamps on Graph
ユーザー NoaSaberNoaSaber
提出日時 2021-04-16 23:28:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 113,156 KB
最終ジャッジ日時 2023-09-16 03:06:23
合計ジャッジ時間 17,493 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,972 KB
testcase_01 AC 73 ms
71,424 KB
testcase_02 AC 72 ms
71,048 KB
testcase_03 WA -
testcase_04 AC 78 ms
70,952 KB
testcase_05 AC 79 ms
71,048 KB
testcase_06 AC 78 ms
71,044 KB
testcase_07 AC 78 ms
71,212 KB
testcase_08 AC 74 ms
71,136 KB
testcase_09 AC 72 ms
71,184 KB
testcase_10 AC 71 ms
71,080 KB
testcase_11 AC 72 ms
70,984 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 465 ms
113,156 KB
testcase_33 WA -
testcase_34 AC 311 ms
106,464 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))
edge=[[] for i in range(N)]
score=[0]*N
for i in range(M):
    u,v=map(int,input().split())
    u-=1;v-=1
    if A[u]<A[v]:
        edge[u].append(v)
    if A[v]<A[u]:
        edge[v].append(u)
K=int(input())
B=list(map(int,input().split()))
q=[]
ans=0
for i in B:
    score[i-1]=1
    q.append((A[i-1],i-1))
import heapq
heapq.heapify(q)
ans_l=[]
while q:
    value,next=heapq.heappop(q)
    if score[next]==-1:
        continue
    if score[next]%2==1:
        ans+=1
        ans_l.append(next)
    for i in edge[next]:
        if score[i]==-1:
            continue
        score[i]+=score[next]
        heapq.heappush(q,(-1,i))

    score[next]=-1
print(ans)
for i in ans_l:
    print(i+1)
0