結果
問題 | No.3018 目隠し宝探し |
ユーザー |
|
提出日時 | 2025-01-25 14:58:34 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,874 bytes |
コンパイル時間 | 8,928 ms |
コンパイル使用メモリ | 175,016 KB |
実行使用メモリ | 51,228 KB |
平均クエリ数 | 11.05 |
最終ジャッジ日時 | 2025-01-25 23:37:53 |
合計ジャッジ時間 | 14,176 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 2 WA * 19 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (125 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
#nullable enableusing System.Numerics;var _backend_ = new StandardIOBackend();object? Solve(){var h = Int();var w = Int();int Query(int x, int y){Out("? " + x + " " + y);_backend_.Flush();return Int();}void Answer(int x, int y){Out("! " + x + " " + y);}static int D(int x0, int y0, int x1, int y1){var dx = x0 - x1;var dy = y0 - y1;return dx * dx + dy * dy;}var d0 = Query(1, 1);if (d0 == 0){Answer(1, 1);return null;}var c0 = new List<(int, int)>();for (var i = 1; i <= h; i++) for (var j = 1; j <= w; j++){if (D(i, j, 1, 1) == d0) c0.Add((i, j));}var g1 = new int[h + 1, w + 1];var mc = int.MaxValue;for (var i = 1; i <= h; i++) for (var j = 1; j <= w; j++){foreach (var (ci, cj) in c0){if (D(i, j, ci, cj) == d0) g1[i, j]++;}if (g1[i, j] > 0) mc = Math.Min(mc, g1[i, j]);}var f = true;for (var i = 1; i <= h; i++) for (var j = 1; j <= w; j++){if (g1[i, j] == mc){var d1 = -1;if (f){d1 = Query(i, j);f = false;}else d1 = 0;if (d1 == 0){Answer(i, j);break;}}}return null;}#regionAtCoderIO _io_;_io_ = new(){ Backend = _backend_ };Out(Solve());_backend_.Flush();string String() => _io_.Next();int Int() => int.Parse(String());void Out(object? x, string? sep = null) => _io_.Out(x, sep ?? Environment.NewLine);class AtCoderIO{public required StandardIOBackend Backend { get; init; }Memory<string> _input = Array.Empty<string>();int _iter = 0;public string Next(){while (_iter >= _input.Length) (_input, _iter) = (Backend.ReadLine().Trim().Split(' '), 0);return _input.Span[_iter++];}public void Out(object? x, string separator){if (x == null) return;if (x is System.Collections.IEnumerable a and not string){var objects = a.Cast<object>();if (!objects.Any()) return;x = string.Join(separator, objects);}Backend.WriteLine(x);}}class StandardIOBackend{readonly StreamReader _sr = new(Console.OpenStandardInput());readonly StreamWriter _sw = new(Console.OpenStandardOutput()) { AutoFlush = false };public string ReadLine() => _sr.ReadLine()!;public void WriteLine(object? value) => _sw.WriteLine(value);public void Flush() => _sw.Flush();}#endregionstatic class Extensions{public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();}