This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |