이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
/// #define int ll
const int oo = 1e9 + 7;
int Guess(int v);
int HC(int N) {
int lo = 1, hi = N, pr = (2 * N - 2) / 3;
pr = max(1, pr); pr = min(N, pr);
Guess(pr);
while(lo < hi) {
int to = (lo + hi) / 2;
if(to == pr && to - 1 >= lo) to--;
if(to == pr && to + 1 <= hi) to++;
if(to == pr) return to;
int r = Guess(to), md = abs(to - pr);
if(md & 1) md++;
if(r == 0) return (to + pr) / 2;
else if((r == 1 && to > pr) || (r == -1 && to < pr))
lo = max(lo, (to + pr) / 2 + 1);
else hi = min(hi, (to + pr + 1) / 2 - 1);
pr = to;
}
return lo;
}
# | 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... |