RoAlgo Contest #12 - NiceContest | X. Nice Guess

This was the problem page during the contest. Access the current page here.
Time limit: 0.05s Memory limit: 1MB Input: Output:

Task

AA and BB are playing a mind-bending game. AA has an unknown number, xx, which BB needs to guess. The function guess(v) returns 11 if vxv \geq x, 00 otherwise. Use the minimum number of calls to the guess function to score 100100 points.

Interaction Protocol

The contestant must implement the function with the header:
int solve(void);

The contestant can use the function defined in interaction.h with the header:
int guess(int val);

Constraints and clarifications

  • 1x1 000 000 0001 \leq x \leq 1\ 000\ 000\ 000
  • Let kk be the number of calls to the guess function made by the contestant.
  • For tests worth 1010 points, kk can be at most 3232.
  • For the other tests, kk should be at most 00.
  • You can use the sample grader from the attachments.
  • This video could prove helpful in finding the 100100 point solution.

Example interaction

Let x=5x = 5.

The grader calls the function solve().

The contestant guesses 66, where guess(6) = 11.

The contestant guesses 44, where guess(4) = 00.

The function solve() returns 55.

The number of calls to the guess function is 22, which is sufficient for the 1010-point subtask but not sufficient for the rest.

Log in or sign up to be able to send submissions!