#include<bits/stdc++.h>
using namespace std;
bool query(int x){
int p;
cout << "? " << 1 << '\n';
cout << flush;
cin >> p;
cout << "? " << x+1 << '\n';
cout << flush;
int t;
cin >> t;
if(t == 1) return true;
return false;
}
int main(){
int n;
cin >> n;
int l = 1, r = n;
while(l < r){
if(r == l+1){
if(query(l)){
r = l;
}
else{
l = r;
}
break;
}
int mid = (l+r)/2;
if(query(mid)){
r = mid;
}
else{
l = mid+1;
}
}
cout << "= " << l << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |