結果

問題 No.2427 Tree Distance Two
ユーザー hato336hato336
提出日時 2023-08-18 21:16:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 600 ms / 2,000 ms
コード長 318 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 127,744 KB
最終ジャッジ日時 2024-05-06 02:58:29
合計ジャッジ時間 11,954 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,840 KB
testcase_01 AC 39 ms
51,584 KB
testcase_02 AC 41 ms
51,840 KB
testcase_03 AC 599 ms
114,816 KB
testcase_04 AC 36 ms
51,840 KB
testcase_05 AC 600 ms
114,560 KB
testcase_06 AC 37 ms
51,584 KB
testcase_07 AC 499 ms
127,200 KB
testcase_08 AC 529 ms
126,592 KB
testcase_09 AC 509 ms
125,824 KB
testcase_10 AC 524 ms
127,744 KB
testcase_11 AC 516 ms
125,104 KB
testcase_12 AC 557 ms
122,808 KB
testcase_13 AC 552 ms
119,936 KB
testcase_14 AC 297 ms
113,024 KB
testcase_15 AC 39 ms
51,840 KB
testcase_16 AC 37 ms
52,224 KB
testcase_17 AC 36 ms
51,840 KB
testcase_18 AC 37 ms
52,096 KB
testcase_19 AC 35 ms
52,096 KB
testcase_20 AC 89 ms
77,056 KB
testcase_21 AC 94 ms
77,440 KB
testcase_22 AC 82 ms
74,880 KB
testcase_23 AC 89 ms
74,496 KB
testcase_24 AC 97 ms
77,184 KB
testcase_25 AC 185 ms
86,144 KB
testcase_26 AC 374 ms
99,840 KB
testcase_27 AC 269 ms
93,056 KB
testcase_28 AC 555 ms
111,616 KB
testcase_29 AC 487 ms
107,264 KB
testcase_30 AC 365 ms
99,328 KB
testcase_31 AC 232 ms
91,136 KB
testcase_32 AC 349 ms
98,944 KB
testcase_33 AC 348 ms
96,128 KB
testcase_34 AC 139 ms
82,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
cnt = [0 for i in range(n)]
edge = [[] for i in range(n)]
for i in range(n-1):
    u,v = map(int,input().split())
    u-=1
    v-=1
    cnt[u] += 1
    cnt[v] += 1
    edge[u].append(v)
    edge[v].append(u)
for i in range(n):
    ans = 0
    for j in edge[i]:
        ans += cnt[j] - 1
    print(ans)
0