NOI Contest Archive

Archive / 2020 / May 2020

Dahara Croft

Easy · National Olympiad in Informatics Sri Lanka - May 2020

Dahara is playing a video game where in each level, she has to unlock a door to collect the treasure and reach the next level.

Each door has a digital lock which can be unlocked by entering a password (PIN) with N number of digits. When Dahara enters a password into the lock, one of the following can happen.

  1. The display of the lock will show number 0, and the door will open
  2. The display of the lock will show number 1, indicating the password is greater than the entered value
  3. The display of the lock will show number -1, indicating the password is less than the entered value
  4. The display of the lock will show number -2, indicating that the maximum number of consecutive attempts has reached

Dahara has only X number of attempts to guess and enter the password. If she doesn’t enter the correct password within X number of attempts, she loses the game and has to start from the beginning. In addition, if Dahara figures out the password without using all the attempts, the game offers bonus points.

Being the genius she is, she decided to write a computer program to find the password with the minimum number of attempts. And she’s asking your help to complete the program.

This is an interactive problem. You have to complete the solve function given in the editor. You can call the function attempt with the password you want to try. It will return an integer, that can be one of the following 4 values,

The score for each test case is calculated based on the number of attempts you used, using the following formula,

$ score = \frac{X -\ no.\ of\ attempts}{X - log_2(10^N - 1)} \times 100\%$

Input Format

You should not read from the standard input, or else your solution will be considered as invalid.
The solve function will receive 2 arguments,

  1. N (int) - number of digits in the password
  2. X (int64) - maximum number of attempts

Output Format

You should not write anything to the standard output, or else your solution will be considered as invalid.
The attempt function will accept a single argument,

  1. password (string) - the password you are attempting

This function will return an int denoting the result as explained above.

Data Types

Notes

Constraints

Limits

Sample Input 0

1 10
4

Sample Output 0

1 1 0

Sample Input 1

2 60
11

Sample Output 1

1 1 0