結果

問題 No.2427 Tree Distance Two
ユーザー hiro1729hiro1729
提出日時 2023-09-11 08:36:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 889 ms / 2,000 ms
コード長 254 bytes
コンパイル時間 1,434 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 130,532 KB
最終ジャッジ日時 2023-09-11 08:36:55
合計ジャッジ時間 22,332 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,216 KB
testcase_01 AC 77 ms
71,196 KB
testcase_02 AC 74 ms
71,256 KB
testcase_03 AC 889 ms
118,584 KB
testcase_04 AC 75 ms
71,428 KB
testcase_05 AC 867 ms
119,428 KB
testcase_06 AC 74 ms
71,276 KB
testcase_07 AC 667 ms
129,332 KB
testcase_08 AC 711 ms
129,068 KB
testcase_09 AC 653 ms
128,284 KB
testcase_10 AC 678 ms
130,532 KB
testcase_11 AC 697 ms
127,784 KB
testcase_12 AC 738 ms
125,824 KB
testcase_13 AC 767 ms
123,548 KB
testcase_14 AC 423 ms
117,548 KB
testcase_15 AC 75 ms
71,436 KB
testcase_16 AC 74 ms
71,192 KB
testcase_17 AC 73 ms
71,196 KB
testcase_18 AC 74 ms
71,232 KB
testcase_19 AC 76 ms
71,328 KB
testcase_20 AC 137 ms
78,408 KB
testcase_21 AC 138 ms
78,972 KB
testcase_22 AC 132 ms
78,224 KB
testcase_23 AC 125 ms
77,632 KB
testcase_24 AC 138 ms
78,100 KB
testcase_25 AC 285 ms
88,628 KB
testcase_26 AC 525 ms
102,724 KB
testcase_27 AC 404 ms
95,748 KB
testcase_28 AC 779 ms
115,676 KB
testcase_29 AC 684 ms
112,040 KB
testcase_30 AC 523 ms
102,604 KB
testcase_31 AC 361 ms
93,428 KB
testcase_32 AC 511 ms
102,000 KB
testcase_33 AC 454 ms
98,744 KB
testcase_34 AC 217 ms
84,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
g = [[] for _ in range(n)]
d = [0 for _ in range(n)]
for _ in range(n - 1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	d[a] += 1
	d[b] += 1
	g[a].append(b)
	g[b].append(a)
for i in range(n):
	print(sum(d[j] for j in g[i]) - d[i])
0