結果

問題 No.513 宝探し2
ユーザー latte0119
提出日時 2017-05-05 22:29:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 159,344 KB
実行使用メモリ 25,476 KB
平均クエリ数 53.42
最終ジャッジ日時 2024-07-17 00:56:17
合計ジャッジ時間 2,603 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x,y;
    int lb=-1,ub=100000;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        int a,b;

        cout<<0<<" "<<mid<<endl;
        cin>>a;
        if(a==0)return 0;
        cout<<0<<" "<<mid+1<<endl;
        cin>>b;
        if(b==0)return 0;
        if(a>b)lb=mid;
        else ub=mid;
    }

    y=ub;
    lb=-1;ub=100000;

    while(ub-lb>1){
        int mid=(ub+lb)/2;
        int a,b;

        cout<<mid<<" "<<y<<endl;
        cin>>a;
        if(a==0)return 0;
        cout<<mid+1<<" "<<y<<endl;
        cin>>b;
        if(b==0)return 0;
        if(a>b)lb=mid;
        else ub=mid;
    }

    x=ub;

    cout<<x<<" "<<y<<endl;
    int latte;
    cin>>latte;
    assert(latte==0);
    return 0;
}
0