#include <iostream>
#include <assert.h>
#include "grader.h"
using namespace std;
int HC(int n)
{
int min = 1, max = n, previous_guess = 1, guess = 0, hot_cool;
Guess(1);
while (min < max)
{
assert(min > 0 && min <= n);
assert(max > 0 && max <= n);
guess = min + max - previous_guess;
hot_cool = Guess(guess);
if (hot_cool == 0)
{
assert((previous_guess + guess + 1) & 1);
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
25 ms |
7544 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
7544 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
27 ms |
7544 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2197 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |