이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |