結果

問題 No.1817 Reversed Edges
ユーザー wolgnik
提出日時 2022-01-21 22:06:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,920 KB
実行使用メモリ 98,936 KB
最終ジャッジ日時 2024-11-26 00:19:01
合計ジャッジ時間 4,420 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
e = [[] for _ in range(N + 1)]

for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)


sm = 0
dp = [0] * (N + 1)
s = [1]
vis = [0] * (N + 1)
vis[1] = 1
while len(s):
  x = s.pop()
  for y in e[x]:
    if vis[y]: continue
    vis[y] = 1
    s.append(y)
    dp[y] = dp[x]
    if x < y: dp[y] += 1

for res in dp[1: ]: print(res)
0