結果

問題 No.2427 Tree Distance Two
ユーザー 👑 H20H20
提出日時 2023-08-18 21:25:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 554 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 154,752 KB
最終ジャッジ日時 2024-05-06 03:14:00
合計ジャッジ時間 11,586 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,968 KB
testcase_01 AC 36 ms
51,840 KB
testcase_02 AC 39 ms
51,456 KB
testcase_03 AC 549 ms
144,512 KB
testcase_04 AC 37 ms
51,328 KB
testcase_05 AC 554 ms
144,896 KB
testcase_06 AC 37 ms
51,840 KB
testcase_07 AC 484 ms
154,412 KB
testcase_08 AC 499 ms
148,096 KB
testcase_09 AC 501 ms
154,752 KB
testcase_10 AC 528 ms
149,120 KB
testcase_11 AC 515 ms
153,608 KB
testcase_12 AC 518 ms
154,168 KB
testcase_13 AC 529 ms
150,528 KB
testcase_14 AC 361 ms
143,104 KB
testcase_15 AC 39 ms
51,840 KB
testcase_16 AC 41 ms
52,480 KB
testcase_17 AC 38 ms
51,840 KB
testcase_18 AC 39 ms
52,224 KB
testcase_19 AC 41 ms
52,224 KB
testcase_20 AC 98 ms
77,184 KB
testcase_21 AC 101 ms
77,056 KB
testcase_22 AC 92 ms
77,184 KB
testcase_23 AC 90 ms
76,800 KB
testcase_24 AC 98 ms
77,184 KB
testcase_25 AC 185 ms
94,080 KB
testcase_26 AC 356 ms
118,400 KB
testcase_27 AC 261 ms
107,136 KB
testcase_28 AC 509 ms
139,520 KB
testcase_29 AC 434 ms
131,584 KB
testcase_30 AC 332 ms
117,376 KB
testcase_31 AC 251 ms
103,168 KB
testcase_32 AC 332 ms
116,992 KB
testcase_33 AC 294 ms
112,256 KB
testcase_34 AC 153 ms
87,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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