#include <bits/stdc++.h>
using namespace std;
#define int long long
int N;
inline int getvalid(int N) {
int mincur = 0;
int cur = 0;
int mini = 1, maxi = N;
bool parity = false;
while (mini < maxi) {
int mid = (mini+maxi)>>1;
if (!parity) {
cur += mid;
} else {
cur -= mid;
}
mini = mid+1;
parity ^= 1;
mincur = min(mincur, cur);
}
return -mincur;
}
inline bool query(int x) {
cout << "? " << x+1 << '\n' << flush;
bool ret;
cin >> ret;
return ret;
}
signed main() {
//ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> N;
int cur = getvalid(N);
int mini = 1, maxi = N;
query(cur);
bool parity = false;
while (mini < maxi) {
int mid = (mini+maxi)>>1;
if (!parity) {
cur += mid;
} else {
cur -= mid;
}
if (query(cur)) {
maxi = mid;
} else {
mini = mid+1;
}
parity ^= 1;
}
cout << "= " << mini << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |