#include "bits/stdc++.h"
using namespace std;
signed main () {
int n;
cin >> n;
map <int,pair <int,int>> mp;
set <int> s;
for(int i = 1; i <= n; i ++) s.insert(i);
int need = n;
for(int i = 1; i < need; i ++, need --) {
mp[need-i] = {i, need};
}
need = n - 1;
for(int i = 1; i < need; i ++, need --) {
mp[need-i] = {i, need};
}
int l = 1, r = n-1, cnt = 0;
pair <int,int> prev = {-1,-1};
while(l < r) {
int mid = (l + r) / 2;
cout << l << " " << r << " " << mid << "\n";
int x;
if(prev.second == mp[mid].first) {
cnt ++;
cout << "? " << mp[mid].second << endl;
s.erase(mp[mid].second);
prev = {mp[mid].first, mp[mid].second};
cin >> x;
} else if (prev.second == mp[mid].second) {
cnt ++;
cout << "? " << mp[mid].first << endl;
s.erase(mp[mid].first);
prev = {mp[mid].second, mp[mid].first};
cin >> x;
}else {
cnt += 2;
cout << "? " << mp[mid].first << endl;
cin >> x;
cout << "? " << mp[mid].second << endl;
s.erase(mp[mid].first);
s.erase(mp[mid].second);
prev = {mp[mid].first, mp[mid].second};
cin >> x;
}
if(x == 1) r = mid;
else l = mid + 1;
}
assert(cnt <= 64);
cout << "= " << r;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
440 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
440 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
440 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
440 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
440 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |