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;
signed main() {
int n;
cin >> n;
set<int>st;
int c;
if (n == 2) {
cout << "? 1" << endl; cin >> c;
cout << "? 2" << endl; cin >> c;
if (c == 1) cout << "= 1" << endl;
else cout << "= 2" << endl;
return 0;
} else if (n == 3) {
cout << "? 2" << endl; cin >> c;
cout << "? 3" << endl; cin >> c;
if (c == 1) cout << "= 1" << endl;
else {
cout << "? 1" << endl; cin >> c;
if (c == 1) cout << "= 2" << endl;
else cout << "= 3" << endl;
}
return 0;
}
int l = 1, r = n, t = 1, ans= n;
cout << "? " << 1 << endl; cin >> c;
while (ans > 1) {
if (t) {
r--;
assert(st.find(r) == st.end());
cout << "? " << r << endl;
} else {
l++;
assert(st.find(l) == st.end());
cout << "? " << l << endl;
}
t ^= 1;
cin >> c;
if (c == 1) ans = r - l;
else break;
}
cout << "= " << ans << endl;
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... |