Submission #1186513

#TimeUsernameProblemLanguageResultExecution timeMemory
1186513nagorn_phGuess the number (BOI20_guess)C++20
100 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ordered_set <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>

#define int long long
#define double long double
#define pii pair <int, int>
#define tiii tuple <int, int, int>
#define emb emplace_back
#define all(a) a.begin(), a.end()
#define iShowSpeed cin.tie(NULL)->sync_with_stdio(false)

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

int32_t main(){
    int n; cin >> n;
    int l = 1, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        cout << "?" << " " << mid << endl;
        int a; cin >> a;
        if (a == -1) l = mid + 1;
        else if (a == 0) return cout << "= " << mid, 0;
        else r = mid - 1;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...