結果

問題 No.2427 Tree Distance Two
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-08-18 22:24:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 631 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 131,840 KB
最終ジャッジ日時 2024-05-06 04:40:44
合計ジャッジ時間 12,677 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,096 KB
testcase_01 AC 35 ms
51,456 KB
testcase_02 AC 34 ms
52,352 KB
testcase_03 AC 628 ms
114,432 KB
testcase_04 AC 36 ms
51,840 KB
testcase_05 AC 622 ms
114,560 KB
testcase_06 AC 34 ms
51,840 KB
testcase_07 AC 534 ms
131,840 KB
testcase_08 AC 590 ms
129,664 KB
testcase_09 AC 566 ms
130,560 KB
testcase_10 AC 577 ms
131,200 KB
testcase_11 AC 580 ms
130,216 KB
testcase_12 AC 613 ms
126,444 KB
testcase_13 AC 631 ms
122,496 KB
testcase_14 AC 315 ms
112,896 KB
testcase_15 AC 36 ms
51,840 KB
testcase_16 AC 36 ms
52,224 KB
testcase_17 AC 34 ms
52,096 KB
testcase_18 AC 36 ms
52,608 KB
testcase_19 AC 36 ms
51,968 KB
testcase_20 AC 94 ms
77,056 KB
testcase_21 AC 100 ms
77,312 KB
testcase_22 AC 85 ms
76,928 KB
testcase_23 AC 84 ms
76,800 KB
testcase_24 AC 95 ms
77,184 KB
testcase_25 AC 183 ms
86,272 KB
testcase_26 AC 394 ms
99,584 KB
testcase_27 AC 287 ms
93,056 KB
testcase_28 AC 602 ms
111,872 KB
testcase_29 AC 509 ms
107,648 KB
testcase_30 AC 380 ms
99,200 KB
testcase_31 AC 247 ms
91,008 KB
testcase_32 AC 364 ms
98,688 KB
testcase_33 AC 325 ms
96,768 KB
testcase_34 AC 147 ms
82,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

sizes = [0]*n

e = [[] for i in range(n)]

for i in range(n-1):
    u,v = [int(x)-1 for x in input().split()]
    sizes[u] += 1
    sizes[v] += 1
    e[u].append(v)
    e[v].append(u)


for i in range(n):

    nums = 0
    for nex in e[i]:
        nums += sizes[nex]-1
    print(nums)
0