結果
問題 | No.2695 Warp Zone |
ユーザー | tobisatis |
提出日時 | 2024-03-22 22:11:36 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 2,788 bytes |
コンパイル時間 | 7,368 ms |
コンパイル使用メモリ | 157,508 KB |
実行使用メモリ | 178,636 KB |
最終ジャッジ日時 | 2024-03-22 22:11:55 |
合計ジャッジ時間 | 10,977 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 64 ms
32,164 KB |
testcase_01 | AC | 65 ms
32,164 KB |
testcase_02 | AC | 64 ms
32,036 KB |
testcase_03 | AC | 137 ms
33,828 KB |
testcase_04 | AC | 135 ms
33,828 KB |
testcase_05 | AC | 135 ms
33,828 KB |
testcase_06 | AC | 136 ms
33,828 KB |
testcase_07 | AC | 136 ms
33,828 KB |
testcase_08 | AC | 66 ms
32,164 KB |
testcase_09 | AC | 95 ms
33,444 KB |
testcase_10 | AC | 66 ms
32,036 KB |
testcase_11 | AC | 79 ms
33,316 KB |
testcase_12 | AC | 106 ms
33,572 KB |
testcase_13 | AC | 65 ms
32,164 KB |
testcase_14 | AC | 115 ms
33,572 KB |
testcase_15 | AC | 94 ms
33,572 KB |
testcase_16 | AC | 78 ms
33,316 KB |
testcase_17 | AC | 84 ms
33,316 KB |
testcase_18 | AC | 126 ms
33,700 KB |
testcase_19 | AC | 66 ms
32,164 KB |
testcase_20 | AC | 123 ms
33,572 KB |
testcase_21 | AC | 116 ms
33,572 KB |
testcase_22 | AC | 89 ms
33,444 KB |
testcase_23 | AC | 104 ms
33,572 KB |
testcase_24 | AC | 65 ms
32,164 KB |
testcase_25 | AC | 67 ms
32,164 KB |
testcase_26 | AC | 67 ms
178,636 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (100 ms)。 MSBuild のバージョン 17.7.3+8ec440e68 (.NET) main -> /home/judge/data/code/bin/Release/net7.0/main.dll main -> /home/judge/data/code/bin/Release/net7.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 AtCoder { object? Solve() { var h = Int(); var w = Int(); var n = Int(); var warps = new ((int, int), (int, int))[n]; for (var i = 0; i < n; i++) { var a = Int(); var b = Int(); var c = Int(); var d = Int(); warps[i] = ((a, b), (c, d)); } var dz = new Dictionary<(int, int), int>(); var q = new PriorityQueue<(int, int, int), int>(); dz[(1, 1)] = 0; q.Enqueue((1, 1, 0), 0); while (q.Count > 0) { var (u, v, k) = q.Dequeue(); if ((u, v) == (h, w)) continue; if (k > dz[(u, v)]) continue; foreach (var ((a, b), (c, d)) in warps) { var dd = k + Math.Abs(u - a) + Math.Abs(v - b) + 1; if (dz.TryGetValue((c, d), out var dn)) if (dn <= dd) continue; dz[(c, d)] = dd; q.Enqueue((c, d, dd), dd); } { var (a, b) = (h, w); var (c, d) = (h, w); var dd = k + Math.Abs(u - a) + Math.Abs(v - b); if (dz.TryGetValue((c, d), out var dn)) if (dn <= dd) continue; dz[(c, d)] = dd; q.Enqueue((c, d, dd), dd); } } return dz[(h, w)]; } 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 }