結果

問題 No.513 宝探し2
ユーザー t98slidert98slider
提出日時 2023-04-17 01:25:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 1,738 ms
コンパイル使用メモリ 164,332 KB
実行使用メモリ 25,220 KB
平均クエリ数 56.42
最終ジャッジ日時 2024-04-20 10:27:36
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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