結果

問題 No.2427 Tree Distance Two
ユーザー Nikkuniku029Nikkuniku029
提出日時 2023-08-18 21:29:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,877 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 83,072 KB
最終ジャッジ日時 2024-05-06 03:21:00
合計ジャッジ時間 5,359 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,880 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 28 ms
10,496 KB
testcase_03 AC 1,860 ms
70,400 KB
testcase_04 AC 27 ms
10,880 KB
testcase_05 AC 1,845 ms
70,528 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 1,772 ms
81,408 KB
testcase_08 AC 1,877 ms
83,072 KB
testcase_09 AC 1,839 ms
82,176 KB
testcase_10 AC 1,846 ms
83,072 KB
testcase_11 AC 1,769 ms
80,256 KB
testcase_12 AC 1,778 ms
77,952 KB
testcase_13 AC 1,839 ms
75,904 KB
testcase_14 AC 1,441 ms
69,760 KB
testcase_15 AC 26 ms
10,880 KB
testcase_16 AC 27 ms
10,752 KB
testcase_17 AC 25 ms
10,752 KB
testcase_18 AC 26 ms
10,752 KB
testcase_19 AC 26 ms
10,752 KB
testcase_20 AC 64 ms
12,672 KB
testcase_21 AC 72 ms
12,800 KB
testcase_22 AC 38 ms
11,392 KB
testcase_23 AC 33 ms
11,008 KB
testcase_24 AC 62 ms
12,672 KB
testcase_25 AC 429 ms
26,624 KB
testcase_26 AC 1,110 ms
47,872 KB
testcase_27 AC 787 ms
37,632 KB
testcase_28 AC 1,729 ms
66,176 KB
testcase_29 AC 1,470 ms
59,520 KB
testcase_30 AC 1,097 ms
46,720 KB
testcase_31 AC 678 ms
34,304 KB
testcase_32 AC 1,066 ms
46,464 KB
testcase_33 AC 926 ms
42,496 KB
testcase_34 AC 282 ms
20,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Edge = [[] for _ in range(N)]
for i in range(N-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    Edge[u].append(v)
    Edge[v].append(u)
ans = [0]*N
# ある頂点vに隣接している頂点同士は+=1となる
for i in range(N):
    v = i
    kouho = Edge[i]
    for j in kouho:
        ans[j] += len(kouho)-1
print(*ans, sep="\n")
0