結果
問題 | No.2888 Mamehinata |
ユーザー |
|
提出日時 | 2024-09-13 21:54:37 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,576 bytes |
コンパイル時間 | 10,365 ms |
コンパイル使用メモリ | 167,568 KB |
実行使用メモリ | 77,952 KB |
最終ジャッジ日時 | 2024-09-13 21:55:38 |
合計ジャッジ時間 | 25,837 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 WA * 6 TLE * 1 -- * 6 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (94 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 enableusing 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;var xz = 2.Repeat(() => n.Repeat(() => n + 1));var q = new Queue<(int, int)>();xz[0][0] = 0;q.Enqueue((0, 0));while (q.Count > 0){var (v, p) = q.Dequeue();var w = xz[p][v];var np = p ^ 1;foreach (var (next, _) in g[v]){if (xz[np][next] < w + 1) continue;xz[np][next] = w + 1;q.Enqueue((next, np));}}var az = new int[n + 1];for (var i = 0; i < n; i++){var j = Math.Min(xz[0][i], xz[1][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();}}