Submission #10086

#TimeUsernameProblemLanguageResultExecution timeMemory
10086gyuntHotter Colder (IOI10_hottercolder)C++98
0 / 100
2247 ms262144 KiB
#include <iostream>
#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)
    {
        guess = min + max - previous_guess;
        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
        {
            if (guess > previous_guess)
                max = mid;
            else
                min = mid + mod;
        }
        
        previous_guess = guess;
    }
    return min;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...