結果

問題 No.2427 Tree Distance Two
ユーザー 👑 rin204rin204
提出日時 2023-09-18 19:09:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 837 ms / 2,000 ms
コード長 279 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 126,412 KB
最終ジャッジ日時 2023-09-18 19:09:55
合計ジャッジ時間 21,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,136 KB
testcase_01 AC 77 ms
70,940 KB
testcase_02 AC 80 ms
71,444 KB
testcase_03 AC 811 ms
113,424 KB
testcase_04 AC 78 ms
71,240 KB
testcase_05 AC 837 ms
113,168 KB
testcase_06 AC 77 ms
71,392 KB
testcase_07 AC 605 ms
125,792 KB
testcase_08 AC 666 ms
125,312 KB
testcase_09 AC 650 ms
124,704 KB
testcase_10 AC 634 ms
126,412 KB
testcase_11 AC 645 ms
124,248 KB
testcase_12 AC 716 ms
121,524 KB
testcase_13 AC 744 ms
119,508 KB
testcase_14 AC 352 ms
111,844 KB
testcase_15 AC 79 ms
71,212 KB
testcase_16 AC 78 ms
71,124 KB
testcase_17 AC 79 ms
71,100 KB
testcase_18 AC 80 ms
71,184 KB
testcase_19 AC 80 ms
71,388 KB
testcase_20 AC 137 ms
78,212 KB
testcase_21 AC 138 ms
78,164 KB
testcase_22 AC 122 ms
78,328 KB
testcase_23 AC 123 ms
78,064 KB
testcase_24 AC 133 ms
78,260 KB
testcase_25 AC 271 ms
86,868 KB
testcase_26 AC 551 ms
99,404 KB
testcase_27 AC 397 ms
93,196 KB
testcase_28 AC 746 ms
111,280 KB
testcase_29 AC 717 ms
107,964 KB
testcase_30 AC 516 ms
99,212 KB
testcase_31 AC 361 ms
91,276 KB
testcase_32 AC 516 ms
98,440 KB
testcase_33 AC 472 ms
96,160 KB
testcase_34 AC 209 ms
83,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append(v)
    edges[v].append(u)

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