結果
問題 | No.2962 Sum Bomb Bomber |
ユーザー |
|
提出日時 | 2024-11-16 15:40:38 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 2,433 bytes |
コンパイル時間 | 11,149 ms |
コンパイル使用メモリ | 168,200 KB |
実行使用メモリ | 46,296 KB |
平均クエリ数 | 213.00 |
最終ジャッジ日時 | 2024-11-16 15:41:02 |
合計ジャッジ時間 | 23,532 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 64 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (87 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(); public static long TernarySearch<T>(long l, long r, Func<long, T> F) where T: IComparable<T> { if (l > r) (l, r) = (r, l); while (r - l > 3) { var w = (r - l) / 3; if (F(l + w).CompareTo(F(r - w)) > 0) l += w; else r -= w; } var res = r; var v = F(r); for (var i = l; i < r; i++) { var c = F(i); if (v.CompareTo(c) > 0) { v = c; res = i; } } return res; } } class AtCoder { object? Solve() { var n = Int(); var max = 1000000000L; var min = -max; long F1(long q) { Out($"1 {q} {max}"); sw.Flush(); return Input<long>(); } var x = Extensions.TernarySearch(min, max, F1); long F2(long q) { Out($"1 {x} {q}"); sw.Flush(); return Input<long>(); } var y = Extensions.TernarySearch(min, max, F2); return $"2 {x} {y}"; } 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(); } }