結果
問題 |
No.3018 目隠し宝探し
|
ユーザー |
![]() |
提出日時 | 2025-01-31 03:16:24 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 160 ms / 2,000 ms |
コード長 | 1,887 bytes |
コンパイル時間 | 13,270 ms |
コンパイル使用メモリ | 171,548 KB |
実行使用メモリ | 50,040 KB |
平均クエリ数 | 2.59 |
最終ジャッジ日時 | 2025-01-31 03:16:46 |
合計ジャッジ時間 | 18,747 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (112 ミリ秒)。 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 void Main() { int H, W; { int[] vs = Console.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(Console.ReadLine()); 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(Console.ReadLine()); 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; } }