結果
問題 | No.2843 Birthday Present Struggle |
ユーザー | tobisatis |
提出日時 | 2024-08-23 22:02:51 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,294 bytes |
コンパイル時間 | 7,110 ms |
コンパイル使用メモリ | 165,056 KB |
実行使用メモリ | 198,404 KB |
最終ジャッジ日時 | 2024-08-23 22:03:05 |
合計ジャッジ時間 | 12,062 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 54 ms
30,072 KB |
testcase_02 | AC | 58 ms
31,224 KB |
testcase_03 | AC | 60 ms
35,652 KB |
testcase_04 | AC | 57 ms
31,616 KB |
testcase_05 | AC | 58 ms
34,668 KB |
testcase_06 | AC | 54 ms
31,360 KB |
testcase_07 | AC | 55 ms
31,232 KB |
testcase_08 | AC | 65 ms
37,520 KB |
testcase_09 | AC | 64 ms
35,108 KB |
testcase_10 | AC | 57 ms
33,408 KB |
testcase_11 | AC | 65 ms
31,616 KB |
testcase_12 | AC | 55 ms
31,616 KB |
testcase_13 | AC | 58 ms
32,896 KB |
testcase_14 | AC | 56 ms
32,640 KB |
testcase_15 | AC | 56 ms
32,128 KB |
testcase_16 | AC | 59 ms
35,788 KB |
testcase_17 | AC | 58 ms
33,008 KB |
testcase_18 | AC | 55 ms
31,616 KB |
testcase_19 | AC | 58 ms
33,024 KB |
testcase_20 | AC | 61 ms
36,036 KB |
testcase_21 | AC | 54 ms
30,208 KB |
testcase_22 | AC | 59 ms
34,916 KB |
testcase_23 | AC | 59 ms
37,420 KB |
testcase_24 | AC | 68 ms
37,728 KB |
testcase_25 | AC | 67 ms
32,128 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 | 63 ms
198,404 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (89 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 moves = new[]{ (-1, 0), (0, -1), (0, 1), (1, 0) }; 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; foreach (var (i, j) in moves) 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 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) { foreach (var (i, j) in moves) { 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(); } }