結果

問題 No.3309 Aging Railway
コンテスト
ユーザー timi
提出日時 2025-11-06 05:43:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 150,564 KB
最終ジャッジ日時 2025-11-06 05:44:07
合計ジャッジ時間 23,647 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
from collections import deque
d=deque()

dp=[[-1]*N for i in range(N)]
D={}
C=[[] for i in range(N)]

A=[]
for i in range(N-1):
  u,v=map(int,input().split())
  u-=1;v-=1
  C[u].append((v,i))
  C[v].append((u,i))
  
for i in range(N):
  V=[-1]*N 
  d=deque()
  d.append((i,10**10))
  V[i]=1 
  while d:
    now,c=d.popleft()
    for nex,p in C[now]:
      cc=min(c,p)
      dp[i][nex]=cc 
      if V[nex]==-1:
        V[nex]=1
        d.append((nex,cc)) 

B=[0]*(N+10)
for i in range(M):
  u,v=map(int,input().split())
  u-=1;v-=1
  B[dp[u][v]]-=1

ans=M 
for i in range(N-1):
  ans+=B[i]
  print(ans)
0