#include <iostream>
#include <assert.h>
#include "grader.h"
using namespace std;
#define MAX_N 1000000
#define min(a, b) (((a) > (b))?(b):(a))
#define max(a, b) (((a) > (b))?(a):(b))
int HC(int n)
{
int min = 1, max = n, previous_guess = 1, guess = 0, hot_cool;
Guess(1);
while (min < max)
{
guess = min + max - previous_guess;
guess = min(guess, n);
guess = max(guess, 1);
hot_cool = Guess(guess);
if (hot_cool == 0)
{
return ((previous_guess + guess) >> 1);
}
int mid = (previous_guess + guess) / 2;
int mod = (previous_guess + guess) & 1;
if (hot_cool > 0)
{
if (guess > previous_guess)
min = mid + mod;
else
max = mid;
}
else
{
//assert(hot_cool < 0);
if (guess > previous_guess)
max = mid;
else
min = mid + mod;
}
previous_guess = guess;
}
return min;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
1272 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
738 ms |
8288 KB |
Output isn't correct - alpha = 0.000000000000 |