結果

問題 No.2962 Sum Bomb Bomber
ユーザー kakel-san
提出日時 2024-12-30 16:32:07
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,709 bytes
コンパイル時間 16,839 ms
コンパイル使用メモリ 167,680 KB
実行使用メモリ 46,936 KB
平均クエリ数 126.95
最終ジャッジ日時 2024-12-30 16:32:56
合計ジャッジ時間 33,921 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 2 WA * 62
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (135 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/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static long NN => long.Parse(ReadLine());
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var max = 100_000_001L;
        var left = -max;
        var right = max;
        var cl = 0L;
        var cr = 0L;
        var clval = 0L;
        var crval = 0L;
        while (right - left > 2)
        {
            cl = (left * 2 + right) / 3;
            clval = CalcX(cl);
            cr = (left + right * 2) / 3;
            crval = CalcX(cl);
            if (clval < crval) right = cr;
            else left = cl;
        }
        var bottom = -max;
        var top = max;
        var cb = 0L;
        var ct = 0L;
        var cbval = 0L;
        var ctval = 0L;
        while (top - bottom > 2)
        {
            cb = (bottom * 2 + top) / 3;
            cbval = CalcY(cb);
            ct = (bottom + top * 2) / 3;
            ctval = CalcY(ct);
            if (cbval < ctval) top = ct;
            else bottom = cb;
        }
        WriteLine($"2 {(clval < crval ? cl : cr)} {(cbval < ctval ? cb : ct)}");
    }
    static Dictionary<long, long> dic = new Dictionary<long, long>();
    static long CalcX(long x)
    {
        if (dic.ContainsKey(x)) return dic[x];
        WriteLine($"1 {x} 0");
        var ans = NN;
        dic[x] = ans;
        return ans;
    }
    static long CalcY(long y)
    {
        if (dic.ContainsKey(y)) return dic[y];
        WriteLine($"1 0 {y}");
        var ans = NN;
        dic[y] = ans;
        return ans;
    }
}
0