結果

問題 No.2427 Tree Distance Two
ユーザー mattu34mattu34
提出日時 2023-08-18 22:43:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 571 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 127,616 KB
最終ジャッジ日時 2024-05-06 05:05:23
合計ジャッジ時間 11,704 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 37 ms
51,584 KB
testcase_02 AC 37 ms
51,840 KB
testcase_03 AC 571 ms
114,560 KB
testcase_04 AC 35 ms
51,840 KB
testcase_05 AC 532 ms
114,432 KB
testcase_06 AC 37 ms
51,712 KB
testcase_07 AC 436 ms
126,824 KB
testcase_08 AC 507 ms
126,720 KB
testcase_09 AC 465 ms
125,824 KB
testcase_10 AC 471 ms
127,616 KB
testcase_11 AC 478 ms
125,072 KB
testcase_12 AC 501 ms
122,820 KB
testcase_13 AC 523 ms
120,320 KB
testcase_14 AC 285 ms
112,640 KB
testcase_15 AC 38 ms
52,224 KB
testcase_16 AC 38 ms
52,352 KB
testcase_17 AC 35 ms
52,096 KB
testcase_18 AC 38 ms
52,480 KB
testcase_19 AC 37 ms
52,096 KB
testcase_20 AC 90 ms
77,440 KB
testcase_21 AC 95 ms
77,568 KB
testcase_22 AC 91 ms
76,672 KB
testcase_23 AC 83 ms
74,624 KB
testcase_24 AC 94 ms
77,056 KB
testcase_25 AC 180 ms
86,400 KB
testcase_26 AC 338 ms
99,584 KB
testcase_27 AC 249 ms
93,184 KB
testcase_28 AC 522 ms
111,104 KB
testcase_29 AC 450 ms
107,136 KB
testcase_30 AC 338 ms
98,816 KB
testcase_31 AC 230 ms
91,136 KB
testcase_32 AC 328 ms
99,072 KB
testcase_33 AC 304 ms
96,640 KB
testcase_34 AC 145 ms
83,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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