結果

問題 No.2427 Tree Distance Two
ユーザー ntudantuda
提出日時 2023-08-19 09:46:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 828 ms / 2,000 ms
コード長 270 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 152,576 KB
最終ジャッジ日時 2024-05-06 17:00:17
合計ジャッジ時間 16,610 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 40 ms
51,840 KB
testcase_02 AC 42 ms
51,840 KB
testcase_03 AC 828 ms
142,336 KB
testcase_04 AC 41 ms
51,968 KB
testcase_05 AC 808 ms
142,208 KB
testcase_06 AC 41 ms
51,456 KB
testcase_07 AC 596 ms
151,140 KB
testcase_08 AC 689 ms
145,920 KB
testcase_09 AC 672 ms
152,576 KB
testcase_10 AC 684 ms
146,816 KB
testcase_11 AC 685 ms
151,304 KB
testcase_12 AC 715 ms
151,800 KB
testcase_13 AC 735 ms
148,568 KB
testcase_14 AC 439 ms
141,056 KB
testcase_15 AC 42 ms
52,224 KB
testcase_16 AC 43 ms
52,352 KB
testcase_17 AC 41 ms
51,968 KB
testcase_18 AC 43 ms
52,864 KB
testcase_19 AC 42 ms
52,224 KB
testcase_20 AC 111 ms
77,056 KB
testcase_21 AC 124 ms
77,184 KB
testcase_22 AC 116 ms
77,056 KB
testcase_23 AC 120 ms
76,800 KB
testcase_24 AC 132 ms
77,184 KB
testcase_25 AC 300 ms
93,312 KB
testcase_26 AC 493 ms
116,992 KB
testcase_27 AC 366 ms
105,216 KB
testcase_28 AC 747 ms
137,196 KB
testcase_29 AC 643 ms
129,920 KB
testcase_30 AC 472 ms
115,968 KB
testcase_31 AC 304 ms
101,760 KB
testcase_32 AC 473 ms
115,584 KB
testcase_33 AC 401 ms
111,104 KB
testcase_34 AC 184 ms
87,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
UV = [list(map(int,input().split())) for _ in range(N-1)]
E = [[] for _ in range(N)]
for u,v in UV:
    u -= 1
    v -= 1
    E[u].append(v)
    E[v].append(u)
for i in range(N):
    ans = 0
    for j in E[i]:
        ans += len(E[j]) - 1
    print(ans)
0