結果
問題 | No.2888 Mamehinata |
ユーザー | tobisatis |
提出日時 | 2024-09-13 22:07:42 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 319 ms / 2,000 ms |
コード長 | 3,576 bytes |
コンパイル時間 | 8,384 ms |
コンパイル使用メモリ | 167,636 KB |
実行使用メモリ | 189,780 KB |
最終ジャッジ日時 | 2024-09-13 22:08:11 |
合計ジャッジ時間 | 20,470 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
30,848 KB |
testcase_01 | AC | 83 ms
30,976 KB |
testcase_02 | AC | 65 ms
30,848 KB |
testcase_03 | AC | 65 ms
30,848 KB |
testcase_04 | AC | 62 ms
30,328 KB |
testcase_05 | AC | 65 ms
30,720 KB |
testcase_06 | AC | 65 ms
30,720 KB |
testcase_07 | AC | 65 ms
30,708 KB |
testcase_08 | AC | 65 ms
30,720 KB |
testcase_09 | AC | 65 ms
30,720 KB |
testcase_10 | AC | 65 ms
30,848 KB |
testcase_11 | AC | 62 ms
30,464 KB |
testcase_12 | AC | 66 ms
30,720 KB |
testcase_13 | AC | 130 ms
54,016 KB |
testcase_14 | AC | 116 ms
48,912 KB |
testcase_15 | AC | 201 ms
65,664 KB |
testcase_16 | AC | 240 ms
68,752 KB |
testcase_17 | AC | 116 ms
48,752 KB |
testcase_18 | AC | 169 ms
62,552 KB |
testcase_19 | AC | 252 ms
69,120 KB |
testcase_20 | AC | 232 ms
66,856 KB |
testcase_21 | AC | 218 ms
67,160 KB |
testcase_22 | AC | 145 ms
55,468 KB |
testcase_23 | AC | 174 ms
59,904 KB |
testcase_24 | AC | 247 ms
73,504 KB |
testcase_25 | AC | 198 ms
65,928 KB |
testcase_26 | AC | 215 ms
70,740 KB |
testcase_27 | AC | 143 ms
58,556 KB |
testcase_28 | AC | 101 ms
42,112 KB |
testcase_29 | AC | 152 ms
53,396 KB |
testcase_30 | AC | 308 ms
72,456 KB |
testcase_31 | AC | 222 ms
69,128 KB |
testcase_32 | AC | 183 ms
61,944 KB |
testcase_33 | AC | 217 ms
69,560 KB |
testcase_34 | AC | 198 ms
61,252 KB |
testcase_35 | AC | 177 ms
60,556 KB |
testcase_36 | AC | 306 ms
71,040 KB |
testcase_37 | AC | 319 ms
74,496 KB |
testcase_38 | AC | 139 ms
52,716 KB |
testcase_39 | AC | 261 ms
68,488 KB |
testcase_40 | AC | 307 ms
71,168 KB |
testcase_41 | AC | 110 ms
43,136 KB |
testcase_42 | AC | 262 ms
68,248 KB |
testcase_43 | AC | 217 ms
70,180 KB |
testcase_44 | AC | 238 ms
72,248 KB |
testcase_45 | AC | 261 ms
78,024 KB |
testcase_46 | AC | 98 ms
41,344 KB |
testcase_47 | AC | 246 ms
71,580 KB |
testcase_48 | AC | 213 ms
71,716 KB |
testcase_49 | AC | 100 ms
43,504 KB |
testcase_50 | AC | 157 ms
63,488 KB |
testcase_51 | AC | 73 ms
33,024 KB |
testcase_52 | AC | 67 ms
31,232 KB |
testcase_53 | AC | 87 ms
37,248 KB |
testcase_54 | AC | 63 ms
189,780 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (95 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/
ソースコード
namespace AtCoder; #nullable enable using System.Numerics; class Graph<T> { public struct Edge { public int Ab { get; set; } public int Ad { get; set; } public T Distance { get; set; } } public int N { get; private init; } public bool Directed { get; private init; } public List<List<(int next, int edgeIndex)>> AdjacencyList { get; private init; } public List<Edge> Edges { get; private init; } public Graph(int verticals, IReadOnlyList<Edge> edges, bool directed) { N = verticals; Directed = directed; AdjacencyList = new List<List<(int, int)>>(); for (var i = 0; i < N; i++) AdjacencyList.Add(new List<(int, int)>()); Edges = new List<Edge>(); for (var i = 0; i < edges.Count; i++) { var edge = edges[i]; Edges.Add(edge); AdjacencyList[edge.Ab].Add((edge.Ad, i)); if (!Directed) AdjacencyList[edge.Ad].Add((edge.Ab, i)); } } } class GraphBuilder { public static Graph<int> SimpleGraph(int verticals, (int ab, int ad)[] edges, bool directed) { var e = edges.Select(e => new Graph<int>.Edge { Ab = e.ab, Ad = e.ad, Distance = 1 }).ToList(); return new(verticals, e, directed); } } static class Extensions { public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } class AtCoder { object? Solve() { var n = Int(); var m = Int(); var edges = m.Repeat(() => (Int() - 1, Int() - 1)); var g = GraphBuilder.SimpleGraph(n, edges, false).AdjacencyList; if (g[0].Count == 0) { Out(new int[n]); return null; } var xz = n.Repeat(() => n + 1); var q = new Queue<int>(); xz[0] = 0; q.Enqueue(0); while (q.Count > 0) { var v = q.Dequeue(); var w = xz[v]; foreach (var (next, _) in g[v]) { if (xz[next] <= w + 1) continue; xz[next] = w + 1; q.Enqueue(next); } } var az = new int[n + 1]; for (var i = 0; i < n; i++) { var j = xz[i]; if (j <= n) az[j]++; } for (var i = 2; i <= n; i++) az[i] += az[i - 2]; Out(az.Skip(1)); return null; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty<string>(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Trim().Split(' '), 0); return input[iter++]; } T Input<T>() where T : IParsable<T> => T.Parse(String(), null); int Int() => Input<int>(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } }