結果
問題 | No.2843 Birthday Present Struggle |
ユーザー | tobisatis |
提出日時 | 2024-08-23 22:00:27 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,354 bytes |
コンパイル時間 | 7,742 ms |
コンパイル使用メモリ | 166,636 KB |
実行使用メモリ | 201,412 KB |
最終ジャッジ日時 | 2024-08-23 22:00:48 |
合計ジャッジ時間 | 19,242 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | WA | - |
testcase_08 | AC | 68 ms
37,392 KB |
testcase_09 | RE | - |
testcase_10 | AC | 62 ms
33,664 KB |
testcase_11 | RE | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | AC | 71 ms
37,856 KB |
testcase_25 | AC | 66 ms
32,256 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 68 ms
201,412 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /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 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 n = Int(); var ax = Int(); var ay = Int(); var bx = Int(); var by = Int(); var cx = Int(); var cy = Int(); var g = new bool[n + 2, n + 2]; for (var i = 1; i <= n; i++) for (var j = 1; j <= n; j++) g[i, j] = true; for (var i = -1; i <= 1; i++) for (var j = -1; j <= 1; j++) g[cx + i, cy + j] = false; var max = int.MaxValue / 2; var dz = new int[n + 2, n + 2]; for (var i = 1; i <= n; i++) for (var j = 1; j <= n; j++) dz[i, j] = max; dz[bx, by] = 0; var lz = new (int, int)[n + 2, n + 2]; var moves = new[]{ (-1, 0), (0, -1), (0, 1), (1, 0) }; var q = new Queue<(int, int)>(); q.Enqueue((bx, by)); while (dz[ax, ay] == max) { var (x, y) = q.Dequeue(); var nd = dz[x, y] + 1; foreach (var (dx, dy) in moves) { var nx = x + dx; var ny = y + dy; if (!g[nx, ny] || dz[nx, ny] <= nd) continue; dz[nx, ny] = nd; lz[nx, ny] = (x, y); q.Enqueue((nx, ny)); } } var paths = new HashSet<(int, int)>(); { var (x, y) = (ax, ay); while ((x, y) != (bx, by)) { paths.Add((x, y)); (x, y) = lz[x, y]; } paths.Add((x, y)); } var ans = new HashSet<(int, int)>(); foreach (var (x, y) in paths) { for (var i = -1; i <= 1; i++) for (var j = -1; j <= 1; j++) { var nx = x + i; var ny = y + j; if (Math.Min(nx, ny) == 0 || Math.Max(nx, ny) == n + 1 || paths.Contains((nx, ny))) continue; ans.Add((nx, ny)); } } Out(ans.Count); foreach (var (x, y) in ans) Out(x + " " + y); 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()!.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(); } }