結果
問題 | No.2674 k-Walk on Bipartite |
ユーザー | tobisatis |
提出日時 | 2024-03-15 22:53:38 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,974 bytes |
コンパイル時間 | 6,931 ms |
コンパイル使用メモリ | 168,004 KB |
実行使用メモリ | 188,636 KB |
最終ジャッジ日時 | 2024-09-30 02:25:37 |
合計ジャッジ時間 | 12,060 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
30,460 KB |
testcase_01 | AC | 56 ms
30,720 KB |
testcase_02 | AC | 55 ms
30,336 KB |
testcase_03 | AC | 56 ms
30,720 KB |
testcase_04 | AC | 55 ms
30,580 KB |
testcase_05 | AC | 55 ms
30,976 KB |
testcase_06 | AC | 53 ms
30,720 KB |
testcase_07 | AC | 143 ms
64,324 KB |
testcase_08 | AC | 169 ms
66,164 KB |
testcase_09 | AC | 136 ms
62,212 KB |
testcase_10 | AC | 181 ms
67,200 KB |
testcase_11 | AC | 148 ms
63,344 KB |
testcase_12 | AC | 180 ms
66,560 KB |
testcase_13 | AC | 130 ms
60,692 KB |
testcase_14 | AC | 87 ms
48,320 KB |
testcase_15 | AC | 187 ms
67,712 KB |
testcase_16 | AC | 160 ms
63,804 KB |
testcase_17 | AC | 158 ms
66,912 KB |
testcase_18 | AC | 112 ms
53,868 KB |
testcase_19 | AC | 146 ms
61,924 KB |
testcase_20 | AC | 133 ms
62,364 KB |
testcase_21 | AC | 167 ms
66,508 KB |
testcase_22 | AC | 197 ms
68,224 KB |
testcase_23 | AC | 54 ms
30,692 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 54 ms
30,464 KB |
testcase_27 | AC | 54 ms
30,720 KB |
testcase_28 | AC | 54 ms
30,720 KB |
testcase_29 | AC | 55 ms
30,588 KB |
testcase_30 | AC | 54 ms
30,720 KB |
testcase_31 | AC | 55 ms
30,336 KB |
testcase_32 | AC | 54 ms
30,580 KB |
testcase_33 | AC | 55 ms
30,720 KB |
testcase_34 | AC | 54 ms
30,976 KB |
testcase_35 | AC | 56 ms
30,592 KB |
testcase_36 | AC | 56 ms
30,720 KB |
testcase_37 | AC | 55 ms
30,336 KB |
testcase_38 | AC | 55 ms
188,636 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (83 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; static class Extensions { public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } 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); } public static Graph<T> Graph<T>(int verticals, (int ab, int ad, T edge)[] edges, bool directed) { var e = edges.Select(e => new Graph<T>.Edge { Ab = e.ab, Ad = e.ad, Distance = e.edge }).ToList(); return new(verticals, e, directed); } } class AtCoder { object? Solve() { var n = Int(); var m = Int(); var s = Int() - 1; var t = Int() - 1; var k = Int(); var edges = m.Repeat(() => (Int() - 1, Int() - 1)); var g = GraphBuilder.SimpleGraph(n, edges, false).AdjacencyList; var max = int.MaxValue / 2; var dz = n.Repeat(() => max); dz[s] = 0; var q = new Queue<int>(); q.Enqueue(s); while (q.Count > 0) { var v = q.Dequeue(); var w = dz[v] + 1; foreach (var (next, _) in g[v]) { if (dz[next] <= w) continue; dz[next] = w; q.Enqueue(next); } } var unknown = "Unknown"; if (dz[t] < max) { if (k % 2 != dz[t] % 2) return false; if (s == t && n == 1) return false; if (dz[t] <= k) return true; return unknown; } if (n == 2 && k % 2 == 0) return false; return unknown; } 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 }; #pragma warning disable IDE0051 string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.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(); } #pragma warning restore IDE0051 }