結果

問題 No.2427 Tree Distance Two
ユーザー KudeKude
提出日時 2023-08-18 21:08:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 829 ms / 2,000 ms
コード長 240 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 127,800 KB
最終ジャッジ日時 2023-08-18 21:08:22
合計ジャッジ時間 16,273 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,276 KB
testcase_01 AC 72 ms
71,148 KB
testcase_02 AC 71 ms
71,208 KB
testcase_03 AC 829 ms
116,968 KB
testcase_04 AC 82 ms
71,388 KB
testcase_05 AC 823 ms
117,016 KB
testcase_06 AC 71 ms
71,492 KB
testcase_07 AC 647 ms
126,268 KB
testcase_08 AC 684 ms
127,564 KB
testcase_09 AC 651 ms
125,720 KB
testcase_10 AC 641 ms
127,800 KB
testcase_11 AC 658 ms
125,532 KB
testcase_12 AC 739 ms
123,312 KB
testcase_13 AC 750 ms
120,728 KB
testcase_14 AC 436 ms
115,024 KB
testcase_15 AC 75 ms
71,452 KB
testcase_16 AC 74 ms
71,292 KB
testcase_17 AC 73 ms
70,988 KB
testcase_18 AC 76 ms
71,196 KB
testcase_19 AC 71 ms
71,056 KB
testcase_20 AC 132 ms
78,440 KB
testcase_21 AC 136 ms
78,828 KB
testcase_22 AC 131 ms
78,124 KB
testcase_23 AC 120 ms
78,076 KB
testcase_24 AC 133 ms
78,328 KB
testcase_25 AC 284 ms
88,652 KB
testcase_26 AC 562 ms
101,600 KB
testcase_27 AC 402 ms
94,396 KB
testcase_28 AC 810 ms
113,768 KB
testcase_29 AC 701 ms
109,740 KB
testcase_30 AC 557 ms
101,044 KB
testcase_31 AC 362 ms
92,756 KB
testcase_32 AC 509 ms
100,352 KB
testcase_33 AC 469 ms
97,712 KB
testcase_34 AC 199 ms
84,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
for u in range(n):
    ans = sum(len(g[v]) - 1 for v in g[u])
    print(ans)
0