This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define endl '\n'
#define pl(var) " [" << #var << ": " << (var) << "] "
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "[" << p.first << ", " << p.second << "]"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "["; for(int i = 0; i < (int)v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}
ll int n;
void solve() {
cin >> n;
assert(n <= 64);
cout << "? 1" << endl;
cout.flush();
int s; cin >> s;
int hi = n, lo = 2;
int prev = 1;
for (int i = 0; i < n - 1; i++) {
if (i % 2 == 0) {
cout << "? " << hi-- << endl;
cout.flush();
cin >> s;
if (i == 0 && !s) {
cout << "= " << n << endl;
return;
}
if (!s) {
cout << "= " << (abs(prev - (hi + 2))) << endl;
return;
}
prev = hi + 1;
} else {
cout << "? " << lo++ << endl;
cout.flush();
cin >> s;
if (!s) {
cout << "= " << (abs(prev - (lo - 2))) << endl;
return;
}
prev = lo - 1;
}
}
// assert(0);
cout << "= 1" << endl;
}
int main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |