結果

問題 No.2427 Tree Distance Two
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-18 21:31:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 663 ms / 2,000 ms
コード長 1,075 bytes
コンパイル時間 3,004 ms
コンパイル使用メモリ 107,904 KB
実行使用メモリ 78,748 KB
最終ジャッジ日時 2024-05-06 03:25:50
合計ジャッジ時間 14,724 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
19,200 KB
testcase_01 AC 27 ms
18,944 KB
testcase_02 AC 27 ms
19,328 KB
testcase_03 AC 586 ms
71,524 KB
testcase_04 AC 29 ms
19,200 KB
testcase_05 AC 663 ms
71,520 KB
testcase_06 AC 29 ms
19,200 KB
testcase_07 AC 560 ms
78,748 KB
testcase_08 AC 573 ms
76,908 KB
testcase_09 AC 569 ms
76,912 KB
testcase_10 AC 542 ms
77,292 KB
testcase_11 AC 563 ms
77,536 KB
testcase_12 AC 583 ms
76,900 KB
testcase_13 AC 583 ms
74,864 KB
testcase_14 AC 447 ms
70,244 KB
testcase_15 AC 28 ms
19,456 KB
testcase_16 AC 27 ms
19,456 KB
testcase_17 AC 28 ms
19,200 KB
testcase_18 AC 28 ms
19,328 KB
testcase_19 AC 27 ms
19,200 KB
testcase_20 AC 38 ms
21,812 KB
testcase_21 AC 41 ms
22,716 KB
testcase_22 AC 31 ms
19,968 KB
testcase_23 AC 29 ms
19,840 KB
testcase_24 AC 39 ms
21,800 KB
testcase_25 AC 144 ms
33,656 KB
testcase_26 AC 342 ms
53,360 KB
testcase_27 AC 254 ms
44,780 KB
testcase_28 AC 566 ms
68,452 KB
testcase_29 AC 456 ms
64,364 KB
testcase_30 AC 333 ms
52,336 KB
testcase_31 AC 219 ms
42,876 KB
testcase_32 AC 353 ms
52,196 KB
testcase_33 AC 300 ms
48,628 KB
testcase_34 AC 104 ms
30,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var map = NMap(n - 1);
        var tree = new List<int>[n];
        for (var i = 0; i < tree.Length; ++i) tree[i] = new List<int>();
        foreach (var edge in map)
        {
            tree[edge[0]].Add(edge[1]);
            tree[edge[1]].Add(edge[0]);
        }
        var ans = new int[n];
        for (var i = 0; i < n; ++i)
        {
            foreach (var next in tree[i])
            {
                ans[next] += tree[i].Count - 1;
            }
        }
        WriteLine(string.Join("\n", ans));
    }
}
0