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 <assert.h>
#include "grader.h"
int HC(int n)
{
int l = 1;
int r = n;
int p = 0;
while (l < r) {
if (p != l && p != r) {
Guess(l);
p = l;
}
int z = r-l+1;
int m = (l+r)/2;
if (p == l) {
int res = Guess(r);
p = r;
if (z%2 == 0) {
if (res == 1) l = m+1;
else if (res == -1) r = m;
else assert(false);
} else {
if (res == 1) l = m+1;
else if (res == -1) r = m-1;
else l = r = m;
}
} else {
int res = Guess(l);
p = l;
if (z%2 == 0) {
if (res == 1) r = m;
else if (res == -1) l = m+1;
else assert(false);
} else {
if (res == 1) r = m-1;
else if (res == -1) l = m+1;
else l = r = m;
}
}
}
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... |