답안 #772323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
772323 2023-07-04T03:00:53 Z Abkonl Hotter Colder (IOI10_hottercolder) C++17
0 / 100
10000 ms 107836 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) {
        cout << "guess: " << guess << endl;
        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;
      cout << "[" << low << "," << high << ']' << endl;
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10065 ms 78044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10072 ms 79124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10077 ms 78076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10036 ms 107836 KB Time limit exceeded