結果

問題 No.2427 Tree Distance Two
ユーザー sotanishysotanishy
提出日時 2023-08-18 21:30:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 647 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 131,328 KB
最終ジャッジ日時 2024-05-06 03:22:38
合計ジャッジ時間 12,585 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,840 KB
testcase_01 AC 41 ms
51,584 KB
testcase_02 AC 42 ms
51,840 KB
testcase_03 AC 647 ms
124,544 KB
testcase_04 AC 43 ms
51,584 KB
testcase_05 AC 634 ms
124,288 KB
testcase_06 AC 42 ms
51,712 KB
testcase_07 AC 453 ms
129,676 KB
testcase_08 AC 500 ms
129,664 KB
testcase_09 AC 476 ms
130,560 KB
testcase_10 AC 480 ms
131,328 KB
testcase_11 AC 481 ms
129,892 KB
testcase_12 AC 539 ms
129,064 KB
testcase_13 AC 584 ms
128,692 KB
testcase_14 AC 259 ms
118,272 KB
testcase_15 AC 43 ms
51,456 KB
testcase_16 AC 43 ms
51,712 KB
testcase_17 AC 42 ms
51,584 KB
testcase_18 AC 42 ms
52,352 KB
testcase_19 AC 42 ms
51,712 KB
testcase_20 AC 82 ms
73,088 KB
testcase_21 AC 92 ms
77,312 KB
testcase_22 AC 73 ms
67,968 KB
testcase_23 AC 71 ms
66,560 KB
testcase_24 AC 85 ms
73,344 KB
testcase_25 AC 190 ms
88,576 KB
testcase_26 AC 392 ms
105,984 KB
testcase_27 AC 288 ms
97,408 KB
testcase_28 AC 588 ms
120,960 KB
testcase_29 AC 520 ms
115,456 KB
testcase_30 AC 386 ms
104,960 KB
testcase_31 AC 256 ms
95,104 KB
testcase_32 AC 385 ms
104,320 KB
testcase_33 AC 337 ms
101,504 KB
testcase_34 AC 147 ms
83,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)
ans = [0] * N
for u in range(N):
    for v in G[u]:
        ans[u] += len(G[v])
    ans[u] -= len(G[u])
print(*ans, sep="\n")
0