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 "grader.h"
int HC(int N) {
//if (N <= 16) {
// Guess(1);
// for (int i = 2; i <= N; i++)
// if (Guess(i) == -1)
// return i - 1;
// return N;
//}
int left = 1;
int right = N;
while (left <= right) {
if (left == right)
return (left + right) / 2;
if (right - left <= 4)
break;
Guess(left);
int temp = Guess(right);
if (temp == 0) // same
return (left + right) / 2;
if (temp == 1) // hotter
left = (left + right) / 2 + 1;
if (temp == -1) // colder
right = (left + right) / 2;
}
int diff = right - left;
if (diff == 0) return left;
if (diff == 1) {
Guess(left);
int temp = Guess(right);
if (temp == -1) return left;
else return right;
}
Guess(left);
for (int i = left + 1; i <= right; i++)
if (Guess(i) == -1)
return i - 1;
return right;
}
# | 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... |