#include "grader.h"
#include<bits/stdc++.h>
using namespace std;
int Guess (int x);
int HC(int N)
{
int low = 1;
int high = N;
int guess = high; // Primeiro palpite é N
int previous_guess = 0;
while (low < high)
{
int response = Guess(guess);
if (response == 1)
{
if (previous_guess > guess)
high = (guess + high) / 2;
if (previous_guess < guess)
low = (guess + low) / 2;
}
else if (response == -1)
{
if (previous_guess > guess)
low = (guess + low) / 2;
if (previous_guess < guess)
high = (guess + high) / 2;
}
previous_guess = guess;
if (response == 0 && guess == previous_guess) // Casos especiais
guess = guess + 1;
if (response != 0) // Padrão
guess = (low + high) / 2;
}
return low;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10023 ms |
1296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10017 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10051 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10040 ms |
8104 KB |
Time limit exceeded |