#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define int long long int
signed main() {
int n; cin >> n;
if (n == 1){
cout << 1 << endl;
return 0;
}
int l = 1, r = n;
int prev = n;
int cur;
while (l < r){
int mid = (l+r)/2;
if (l == r-1) mid = r;
if (mid == n){
cout << "? 1" << endl;
cin >> cur;
cout << "? " << n << endl;
cin >> cur;
if (cur){
cout << "= " << n-1 << endl;
} else {
cout << " " << n << endl;
}
return 0;
}
cout << "? " << 1 << endl;
cin >> cur;
cout << "? " << 1+mid << endl;
cin >> cur;
prev += mid;
if (cur){
if (l == r){
cout << "= " << l << endl;
break;
}
if (l == r-1){
cout << "= " << r << endl;
break;
}
l = mid;
} else {
r = mid-1;
if (l == r-1){
cout << "= " << l << endl;
break;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |