結果

問題 No.2427 Tree Distance Two
ユーザー ShirotsumeShirotsume
提出日時 2023-08-18 21:11:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 645 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 86,664 KB
実行使用メモリ 128,332 KB
最終ジャッジ日時 2023-08-18 21:11:44
合計ジャッジ時間 14,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
74,720 KB
testcase_01 AC 112 ms
74,624 KB
testcase_02 AC 117 ms
74,744 KB
testcase_03 AC 645 ms
117,152 KB
testcase_04 AC 112 ms
74,316 KB
testcase_05 AC 642 ms
117,092 KB
testcase_06 AC 112 ms
74,916 KB
testcase_07 AC 510 ms
128,332 KB
testcase_08 AC 555 ms
128,084 KB
testcase_09 AC 567 ms
127,680 KB
testcase_10 AC 529 ms
128,184 KB
testcase_11 AC 553 ms
126,840 KB
testcase_12 AC 611 ms
124,416 KB
testcase_13 AC 590 ms
122,024 KB
testcase_14 AC 290 ms
115,176 KB
testcase_15 AC 110 ms
74,756 KB
testcase_16 AC 110 ms
74,376 KB
testcase_17 AC 111 ms
74,376 KB
testcase_18 AC 119 ms
74,540 KB
testcase_19 AC 112 ms
74,932 KB
testcase_20 AC 146 ms
82,120 KB
testcase_21 AC 150 ms
82,312 KB
testcase_22 AC 137 ms
81,668 KB
testcase_23 AC 135 ms
80,160 KB
testcase_24 AC 148 ms
82,128 KB
testcase_25 AC 220 ms
90,284 KB
testcase_26 AC 403 ms
103,328 KB
testcase_27 AC 347 ms
97,580 KB
testcase_28 AC 602 ms
114,560 KB
testcase_29 AC 551 ms
110,404 KB
testcase_30 AC 392 ms
102,584 KB
testcase_31 AC 285 ms
95,456 KB
testcase_32 AC 422 ms
102,312 KB
testcase_33 AC 368 ms
99,824 KB
testcase_34 AC 190 ms
86,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

graph = [[] for _ in range(n)]

for _ in range(n - 1):
    u, v = mi()
    u -= 1; v -= 1
    graph[u].append(v)
    graph[v].append(u)

for i in range(n):
    ans = 0
    for to in graph[i]:
        ans += len(graph[to]) - 1
    print(ans)
0