#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int left = 1, right = n, query = n, outcome, last_asked = 2;
cout<<"? 2"<<endl;
cin>>outcome;
while(left < right){
cout<<"? "<<query<<endl;
cin>>outcome;
if(outcome)
right = abs(query-last_asked);
else
left = abs(query-last_asked) + 1;
int mid = left + (right-left)/2;
last_asked = query;
if(query + mid <= n){
query = query + mid;
}
else if(query - mid >= 1){
query = query - mid;
}
else{
query = 1;
}
}
cout<<"= "<<right<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |