結果

問題 No.513 宝探し2
ユーザー peroonperoon
提出日時 2019-06-13 15:08:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,703 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 164,872 KB
実行使用メモリ 24,516 KB
平均クエリ数 26.17
最終ジャッジ日時 2023-09-23 17:19:19
合計ジャッジ時間 3,624 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,000 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 20 ms
23,424 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 21 ms
23,664 KB
testcase_09 AC 21 ms
24,012 KB
testcase_10 WA -
testcase_11 AC 21 ms
24,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#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
#define p_yes() p("Yes")
#define p_no() p("No")

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

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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 = 0;
    ll left_d = query(left, 0);
    ll right = 100000;
    ll right_d = query(right, 0);

    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;
        }else{
            right = center;
        }
    }
    ll center_x = left;

    // Y
    left = 0;
    left_d = query(center_x, left);
    right = 100000;
    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;
        }else{
            right = center;
        }
    }
    
    return 0;
}
0