結果

問題 No.2888 Mamehinata
ユーザー 👑 kakel-sankakel-san
提出日時 2024-09-13 22:14:09
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,441 bytes
コンパイル時間 9,787 ms
コンパイル使用メモリ 167,364 KB
実行使用メモリ 36,352 KB
最終ジャッジ日時 2024-09-13 22:14:30
合計ジャッジ時間 15,163 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
34,048 KB
testcase_01 AC 64 ms
36,352 KB
testcase_02 AC 66 ms
31,104 KB
testcase_03 AC 64 ms
31,104 KB
testcase_04 WA -
testcase_05 AC 65 ms
30,720 KB
testcase_06 AC 64 ms
30,976 KB
testcase_07 AC 64 ms
30,720 KB
testcase_08 AC 65 ms
30,976 KB
testcase_09 AC 65 ms
30,976 KB
testcase_10 AC 64 ms
30,848 KB
testcase_11 WA -
testcase_12 AC 65 ms
30,848 KB
testcase_13 TLE -
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 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var map = NArr(m);
        var tree = new List<int>[n];
        for (var i = 0; i < n; ++i) tree[i] = new List<int>();
        foreach (var edge in map)
        {
            tree[edge[0] - 1].Add(edge[1] - 1);
            tree[edge[1] - 1].Add(edge[0] - 1);
        }
        var dep = Enumerable.Repeat(int.MaxValue / 2, n).ToArray();
        dep[0] = 0;
        DFS(0, -1, tree, dep);
        var ans = new int[n + 1];
        for (var i = 0; i < n; ++i) if (dep[i] <= n) ++ans[dep[i]];
        for (var i = 2; i <= n; ++i) ans[i] += ans[i - 2];
        WriteLine(string.Join("\n", ans.Skip(1)));
    }
    static void DFS(int cur, int prev, List<int>[] tree, int[] dep)
    {
        foreach (var next in tree[cur])
        {
            if (prev == next) continue;
            if (dep[next] <= dep[cur] + 1) continue;
            dep[next] = dep[cur] + 1;
            DFS(next, cur, tree, dep);
        }
    }
}
0