Submission #10085

# Submission time Handle Problem Language Result Execution time Memory
10085 2014-10-10T07:25:09 Z gyunt Hotter Colder (IOI10_hottercolder) C++
0 / 100
2197 ms 262144 KB
#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;
}
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 7544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 7544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 7544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 2197 ms 262144 KB Execution killed with signal 11 (could be triggered by violating memory limits)