結果

問題 No.2427 Tree Distance Two
ユーザー bluemeganebluemegane
提出日時 2023-08-19 06:59:07
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 972 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 63,520 KB
実行使用メモリ 61,016 KB
最終ジャッジ日時 2023-08-19 06:59:16
合計ジャッジ時間 7,182 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
25,112 KB
testcase_01 AC 55 ms
20,744 KB
testcase_02 AC 55 ms
22,780 KB
testcase_03 AC 583 ms
61,016 KB
testcase_04 AC 53 ms
20,640 KB
testcase_05 AC 567 ms
59,304 KB
testcase_06 AC 53 ms
22,600 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        getAns(n);
    }
    static void getAns(int n)
    {
        var aa = new List<int>[n];
        for (int i = 0; i < n; i++) aa[i] = new List<int>();
        for (int i = 0; i < n - 1; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]) - 1;
            aa[a].Add(b);
            aa[b].Add(a);
        }
        var ans = new int[n];
        foreach (var x in aa)
        {
            var m = x.Count;
            if (m <= 1) continue;
            for (int i = 0; i < m - 1; i++)
                for (int j = i + 1; j < m; j++)
                {
                    ans[x[i]]++;
                    ans[x[j]]++;
                }
        }
        Console.WriteLine(string.Join("\n", ans));
    }
}
0