結果

問題 No.513 宝探し2
ユーザー peroonperoon
提出日時 2019-06-13 15:17:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,449 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 164,204 KB
実行使用メモリ 24,312 KB
平均クエリ数 29.08
最終ジャッジ日時 2023-09-24 02:15:26
合計ジャッジ時間 2,863 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,424 KB
testcase_01 AC 26 ms
24,264 KB
testcase_02 AC 26 ms
23,388 KB
testcase_03 AC 25 ms
24,312 KB
testcase_04 AC 25 ms
23,376 KB
testcase_05 AC 25 ms
23,532 KB
testcase_06 AC 25 ms
24,000 KB
testcase_07 AC 25 ms
24,000 KB
testcase_08 AC 26 ms
23,652 KB
testcase_09 AC 26 ms
24,216 KB
testcase_10 AC 27 ms
23,352 KB
testcase_11 AC 27 ms
23,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll query(ll x, ll y){
    p2(x, y);
    ll d;
    cin >> d;
    if(d==0) exit(0);
    return d;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll left = -1;
    ll left_d = query(left, 0);
    ll right = 100000+1;
    ll right_d = query(right, 0);

    // X
    while(left+1!=right){
        ll center = (left+right)/2;
        ll d = query(center, 0);
        
        ll assumed_center_d = left_d - (center-left);
        if(assumed_center_d==d){
            left = center;
            left_d = d;
        }else{
            right = center;
            right_d = d;
        }
    }
    ll center_x = left;

    // Y
    left = -1;
    left_d = query(center_x, left);
    right = 100000+1;
    right_d = query(center_x, right);

    while(left+1!=right){
        ll center = (left+right)/2;
        ll d = query(center_x, center);
        
        ll assumed_center_d = left_d - (center-left);
        if(assumed_center_d==d){
            left = center;
            left_d = d;
        }else{
            right = center;
            right_d = d;
        }
    }
    
    return 0;
}
0