結果

問題 No.2427 Tree Distance Two
ユーザー sotanishysotanishy
提出日時 2023-08-18 21:30:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 618 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 132,368 KB
最終ジャッジ日時 2023-08-18 21:31:00
合計ジャッジ時間 11,879 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,056 KB
testcase_01 AC 70 ms
71,060 KB
testcase_02 AC 69 ms
71,220 KB
testcase_03 AC 618 ms
126,016 KB
testcase_04 AC 69 ms
71,316 KB
testcase_05 AC 599 ms
126,164 KB
testcase_06 AC 69 ms
71,272 KB
testcase_07 AC 416 ms
130,088 KB
testcase_08 AC 449 ms
130,268 KB
testcase_09 AC 417 ms
131,116 KB
testcase_10 AC 427 ms
132,368 KB
testcase_11 AC 462 ms
130,304 KB
testcase_12 AC 479 ms
129,188 KB
testcase_13 AC 547 ms
129,336 KB
testcase_14 AC 248 ms
119,556 KB
testcase_15 AC 70 ms
71,456 KB
testcase_16 AC 70 ms
71,160 KB
testcase_17 AC 71 ms
71,220 KB
testcase_18 AC 71 ms
71,368 KB
testcase_19 AC 71 ms
71,272 KB
testcase_20 AC 101 ms
78,640 KB
testcase_21 AC 102 ms
78,704 KB
testcase_22 AC 93 ms
76,792 KB
testcase_23 AC 89 ms
76,908 KB
testcase_24 AC 101 ms
78,952 KB
testcase_25 AC 169 ms
89,768 KB
testcase_26 AC 325 ms
107,240 KB
testcase_27 AC 256 ms
98,092 KB
testcase_28 AC 500 ms
122,040 KB
testcase_29 AC 437 ms
116,640 KB
testcase_30 AC 362 ms
106,164 KB
testcase_31 AC 219 ms
96,180 KB
testcase_32 AC 319 ms
106,232 KB
testcase_33 AC 309 ms
102,772 KB
testcase_34 AC 154 ms
85,404 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