結果

問題 No.513 宝探し2
コンテスト
ユーザー ngtkana
提出日時 2020-03-17 22:25:27
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 76 ms / 2,000 ms
+ 999µs
コード長 745 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,399 ms
コンパイル使用メモリ 216,848 KB
実行使用メモリ 9,796 KB
平均クエリ数 55.14
最終ジャッジ日時 2026-11-02 03:10:31
合計ジャッジ時間 2,961 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using lint=long long;
lint query(lint x, lint y){
    std::cout<<x<<" "<<y<<std::endl;
    lint ans;
    std::cin>>ans;
    if(!ans)exit(0);
    return ans;
}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint max=100000;
    std::vector<lint>ans(2);
    for(lint i=0;i<2;i++){
        auto cal=[&](lint x){
            std::vector<int>a(2);
            a.at(i)=x;
            return query(a.at(0),a.at(1));
        };
        lint l=0,r=max+1;
        while(1<r-l){
            lint c=(l+r)/2;
            (cal(c-1)>cal(c)?l:r)=c;
        }
        ans.at(i)=l;
    }
    std::cout<<ans.at(0)<<" "<<ans.at(1)<<'\n';
}

0