After hearing some nasty rumours about him, Mike is determined to find the source of the rumour! There are
The rumour spreads according to the following procedure:
- On day
, suspect will create the rumour. - On day
, suspect will tell the rumour to all of their friends. - Then, on day
, the suspects who heard the rumour for the first time on day will tell the rumour to all of their friends who have not yet heard the rumour.
Josh knows who started the rumour, but he is too scared to directly tell Mike, lest he feel the wrath of suspect
Can you help Mike determine who started the rumour?
Constraints
It is guaranteed that all
Subtask 1 [10%]
For
Subtask 2 [10%]
For
Subtask 3 [80%]
No additional constraints.
Note that all previous subtasks must be passed for this subtask to be evaluated.
Interaction
This is an interactive problem, where you will play the role of Mike and the interactor will play the role of Josh. Note that the interactor is adaptive.
First, you should read in the value of
Then, on the
Then, you should begin making queries. To make a query, output an integer
If at any point you make an invalid query, or make more than -1
on the following line. Upon reading this value, you should terminate your program to receive a Wrong Answer verdict. Otherwise, you may receive an arbitrary verdict.
Please note that you may need to flush stdout
after each operation, or interaction may halt. In C++, this can be done with fflush(stdout)
or cout << flush
(depending on whether you use printf
or cout
). In Java, this can be done with System.out.flush()
. In Python, you can use sys.stdout.flush()
.
Sample Interaction
>>>
denotes your output. Do not print this out.
5
1 2
2 3
2 4
1 5
>>> 5
3
>>> 2
4
>>> 4
0
Explanation
In the image above, a line drawn between two suspects indicates a friendship.
In this example,
- Suspect
was first aware of the rumour on day . - Suspect
was first aware of the rumour on day . - Suspects
and were first aware of the rumour on day . - Suspect
was first aware of the rumour on day .
First, Mike guesses that suspect
Then, Mike guesses that suspect
Finally, Mike guesses that suspect
As Mike has successfully guessed the suspect in no more than
Comments