結果

問題 No.513 宝探し2
ユーザー ngtkanangtkana
提出日時 2020-03-17 22:24:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 740 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 200,992 KB
実行使用メモリ 36,388 KB
最終ジャッジ日時 2023-09-23 20:48:21
合計ジャッジ時間 8,887 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
lint query(lint x, lint y){
    std::cout<<x<<" "<<y<<'\n';
    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