結果

問題 No.513 宝探し2
ユーザー t98slider
提出日時 2023-04-17 01:25:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 168,356 KB
実行使用メモリ 25,220 KB
平均クエリ数 56.42
最終ジャッジ日時 2024-10-12 05:59:18
合計ジャッジ時間 3,282 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    auto ask = [&](int x, int y){
        int res;
        cout << x << ' ' << y << endl;
        cin >> res;
        if(res == 0) exit(0);
        return res;
    };
    pair<int, int> mn = {1 << 30, -1};
    int l = 0, r = 100000, c1, c2;
    while(l + 2 < r){
        c1 = (2 * l + r) / 3;
        c2 = (l + 2 * r) / 3;
        int v1 = ask(c1, 0), v2 = ask(c2, 0);
        if(v1 > v2) l = c1;
        else r = c2;
    }
    for(int i = l; i <= r; i++){
        mn = min(mn, make_pair(ask(i, 0), i));
    }
    ask(mn.second, mn.first);
}
0