이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int HC(int N)
{
int l = 1, r = N, lg = -1;
auto gs = [&](int g) -> int {return Guess(lg = g);};
while (r - l > 2)
{
int p = (l * 2 + r) / 3, q = (l + r * 2) / 3;
gs(p);
int fpq = gs(q);
if (!fpq) return (p + q) / 2;
if (~fpq) l = p;
else r = q;
}
if (r - l == 1)
{
if (lg == r) swap(l, r);
return gs(r) ? l : r;
}
if (r - l == 2)
{
if (lg != r && lg != l)
{
if (~gs(r)) return r;
return l + !gs(l);
}
if (lg == r) swap(l, r);
int res = gs(r);
if (!res) return (l + r) / 2;
return ~res ? r : l;
}
return l;
}
# | 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... |