Kings of the Jungle
On the vast plains of the Serengeti lives a clan of lions, each a devoted practitioner of Brazilian Jiu-Jitsu (BJJ). After weeks searching across the golden grass, you have finally found them! Now, you'd like to find the three best fighters of the pride.
You assign each lion a number from to
. Each lion also has a secret skill level, an integer from
to
, and no two lions have the same skill level. The three best fighters are the lions with the three highest skill levels.
You don't know the lions' skill levels, but you can test them. You can choose any two lions to fight, and observe who the winner is. The lion with the higher skill level will always win, and since their skill levels are unique, there will always be a winner.
The sun is setting soon, and the lions are already looking a little sleepy, so you have a limited number of fights to determine who the three best fighters are.
Interaction
This is an interactive problem. Your submission will be run against an interactor, which reads from the standard output of your program and writes to its standard input. The interaction must follow the format below.
The interactor first sends one integer
, the number of lions in the pride.
You may then conduct up to fights to determine the three lions with the highest skill levels. To conduct a fight, print a line in the form
, where
and
, meaning that lions
and
will fight. The interactor will respond with a single integer
, meaning that lion
won the fight.
Once you have determined the three best fighters, print a line in the form , where
, meaning that you believe:
- Lion
has the highest skill level.
- Lion
has the second-highest skill level.
- Lion
has the third-highest skill level.
You will receive a Wrong Answer if:
- You conduct more than
fights, or
- You try to make a lion fight itself (
), or
- You try to make a lion fight that is not in the range
, or
- Your final answer is wrong.
After printing each line, you must flush stdout. Failure to do so may result in an Idleness Limit Exceeded verdict.
For C++, you may use cout << endl to output, or call cout.flush() after each output.
For Python, use flush=True in print(), or call sys.stdout.flush() after each output.
Example
Interaction 1
> 4
< 1 2 ?
> 2
< 3 4 ?
> 3
< 2 3 ?
> 2
< 1 4 ?
> 4
< 2 3 4 !
You conduct the following fights:
- Lion
fights lion
. Lion
wins.
- Lion
fights lion
. Lion
wins.
- Lion
fights lion
. Lion
wins.
- Lion
fights lion
. Lion
wins.
From this, you can determine:
- Lion
has the highest skill level.
- Lion
has the second-highest skill level.
- Lion
has the third-highest skill level.
- Lion
has the lowest skill level (but I'm sure they're great at other stuff!)
Interaction 2
> 3
< 1 2 ?
> 1
< 2 3 ?
> 2
< 1 2 3 !
Comments