結果

問題 No.2427 Tree Distance Two
ユーザー rlangevinrlangevin
提出日時 2023-09-18 14:54:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 1,114 ms
コンパイル使用メモリ 85,700 KB
実行使用メモリ 125,176 KB
最終ジャッジ日時 2023-09-18 14:54:45
合計ジャッジ時間 19,164 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,012 KB
testcase_01 AC 73 ms
71,008 KB
testcase_02 AC 74 ms
71,028 KB
testcase_03 AC 588 ms
114,916 KB
testcase_04 AC 104 ms
71,312 KB
testcase_05 AC 581 ms
115,032 KB
testcase_06 AC 72 ms
71,108 KB
testcase_07 AC 431 ms
123,600 KB
testcase_08 AC 491 ms
123,576 KB
testcase_09 AC 448 ms
123,300 KB
testcase_10 AC 461 ms
125,176 KB
testcase_11 AC 466 ms
122,388 KB
testcase_12 AC 515 ms
121,088 KB
testcase_13 AC 516 ms
119,228 KB
testcase_14 AC 252 ms
113,296 KB
testcase_15 AC 75 ms
71,192 KB
testcase_16 AC 76 ms
70,988 KB
testcase_17 AC 75 ms
71,272 KB
testcase_18 AC 76 ms
71,212 KB
testcase_19 AC 75 ms
71,260 KB
testcase_20 AC 108 ms
78,204 KB
testcase_21 AC 111 ms
78,824 KB
testcase_22 AC 101 ms
76,712 KB
testcase_23 AC 99 ms
76,656 KB
testcase_24 AC 111 ms
78,652 KB
testcase_25 AC 190 ms
87,036 KB
testcase_26 AC 373 ms
100,400 KB
testcase_27 AC 275 ms
94,552 KB
testcase_28 AC 528 ms
112,108 KB
testcase_29 AC 478 ms
107,848 KB
testcase_30 AC 355 ms
99,708 KB
testcase_31 AC 247 ms
91,936 KB
testcase_32 AC 352 ms
99,656 KB
testcase_33 AC 313 ms
97,276 KB
testcase_34 AC 154 ms
83,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
G = [[] for i in range(N)]
for i in range(N - 1):
    u, v = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append(v)
    G[v].append(u)
    
ans = [0] * N
for i in range(N):
    for u in G[i]:
        ans[u] += len(G[i]) - 1
        
for a in ans:
    print(a)
0