結果
問題 |
No.3018 目隠し宝探し
|
ユーザー |
![]() |
提出日時 | 2025-01-28 19:27:17 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 2,176 bytes |
コンパイル時間 | 15,659 ms |
コンパイル使用メモリ | 169,016 KB |
実行使用メモリ | 49,912 KB |
平均クエリ数 | 2.59 |
最終ジャッジ日時 | 2025-01-28 19:27:50 |
合計ジャッジ時間 | 17,479 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (129 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string ReadLine() { return Console.ReadLine().Trim(); } static void Main() { int H, W; { int[] vs = ReadLine().Split().Select(_ => int.Parse(_)).ToArray(); H = vs[0]; W = vs[1]; } if (H == 1 && W == 1) { Console.WriteLine($"! {1} {1}"); return; } bool[,] grid = new bool[H, W]; for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) grid[row, col] = true; } int y = 0; int x = 0; Console.WriteLine($"? {y + 1} {x + 1}"); int d = int.Parse(ReadLine()); if (d == 0) { Console.WriteLine($"! {y + 1} {x + 1}"); return; } if (d == -1) return; if (Check(grid, H, W, y, x, d)) return; x = W - 1; Console.WriteLine($"? {y + 1} {x + 1}"); d = int.Parse(ReadLine()); if (d == 0) { Console.WriteLine($"! {y + 1} {x + 1}"); return; } if (d == -1) return; Check(grid, H, W, y, x, d); } static bool Check(bool[,] grid, int H, int W, int y, int x, int d) { for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { if ((row - y) * (row - y) + (col - x) * (col - x) != d) grid[row, col] = false; } } int hit = 0; int hitX = 0; int hitY = 0; for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { if (grid[row, col]) { hit++; hitY = row; hitX = col; } } } if (hit == 1) { Console.WriteLine($"! {hitY + 1} {hitX + 1}"); return true; } else return false; } }