## Amplitude Hackathon Summer '24 Problem 3 - Mike's Unlocked Laptop

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 1G

Problem type

Mike left his computer unlocked! You know what that means...

Just kidding, Mike would never leave his computer unlocked. However, he did leave his computer on in debugging mode, and Nick has obtained physical access to it. Because Nick is a bad person, he has decided to try to guess Mike's password.

Because Mike's laptop is in debugging mode, when Nick guesses a password, if it is incorrect, Mike's laptop will report the length of the longest common substring between Nick's guess and Mike's true password.

Nick doesn't have a lot of time to guess the password though, are you able to help him?

#### Constraints

Mike's password will only consist of uppercase letters, lowercase letters, and digits. The length of Mike's password will be between and .

#### Subtask 1 [1 point]

Mike's password will have length at most 2.

(Note: Hac would like me to inform all of you that your passwords should never be of length 1 or 2.)

#### Interaction Protocol

The interaction will take place over multiple rounds. In one round, you must output a line containing a guess of Mike's password. Then, you must read in a single integer. Remember to flush your output to standard out before trying to read an integer!

If the guess is exactly equal to Mike's password, then you will read in a value of -1. Your program has correctly guessed the password, and you are considered to have solved this test case. Your program should terminate immediately.

Otherwise, you will read in a nonnegative integer , indicating that the length of the longest common substring between Mike's password and your guess is . After this, you may guess another password.

You have unlimited guesses, but your program must still run within the time limit of the problem specified.

#### Sample Interaction

Note that <<< represents values that you should read from stdin, and >>> represents a string that you print to stdout.

>>> zzz
0 <<<
>>> Mikeisawesome123
14 <<<
>>> Mikeisawesome1
-1 <<<

Note that in this sample interaction, Mike's password was actually Mikeisawesome1.

This test case will be the first test case in the second subtask.