# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1082556 | 2024-08-31T15:31:51 Z | aaaaaarroz | Hotter Colder (IOI10_hottercolder) | C++17 | 0 ms | 0 KB |
#include "grader.h" int HC(int N) { int left = 1, right = N; int last_guess = (left + right) / 2; // Make the first guess Guess(last_guess); int last_distance = abs(last_guess - GuessResult()); // Distance to target (initially unknown) while (left <= right) { int mid = (left + right) / 2; Guess(mid); int current_distance = abs(mid - GuessResult()); if (Guess(mid) == 0) { return mid; // The correct number is found } if (Guess(mid) == 1) { // Hotter if (current_distance < last_distance) { left = mid + 1; } else { right = mid - 1; } } else { // Colder if (current_distance > last_distance) { left = mid + 1; } else { right = mid - 1; } } last_distance = current_distance; last_guess = mid; } return -1; // In case something goes wrong }