Submission #772212

# Submission time Handle Problem Language Result Execution time Memory
772212 2023-07-03T18:13:56 Z Abkonl Hotter Colder (IOI10_hottercolder) C++17
0 / 100
10000 ms 9224 KB
#include "grader.h"
#include <iostream>
using namespace std;

int HC(int N){
  int low = 1;
  int high = N;
  int guess = high; // Primeiro palpite é N
  int prev = 0;
  int response_prev = 0;
  int response_prev_prev = 0;
  int firstGuess = true;

    while (low < high) {

        int response = Guess(guess);
        if (response == 1) {
            if(prev > guess) 
                high = (guess + high)/2;

            if(prev < guess)
                low = (guess + low)/2;
        } 
        else if (response == -1) {
            if(prev > guess)
                low = (guess + low)/2;

            if(prev < guess)
                high = (guess + high)/2;
        }

        if(response == -1 && response_prev == 0 && response_prev_prev == 1) {
          return prev;
        }

        prev = guess;
        response_prev_prev = response_prev;
        response_prev = response;
        if(response == 0 && guess == prev) {//Casos especiais
          if(firstGuess == true) {
            firstGuess = false;
            guess = (low + high) / 2;
          }
          else {
            guess = guess + 1;
          }
        }

        if(response != 0) //Padrão
            guess = (low + high) / 2;

    }
    return low;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 10043 ms 1180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10100 ms 1304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10022 ms 1236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10029 ms 9224 KB Time limit exceeded