| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 8 | 6 | 6 | 75.000% |
In his great quest to rescue princess Zelda and protect the kingdom of Hyrule from the clutches of the evil Ganondorf, you, the hero, have arrived in the Lost Woods to rescue an ancient sage. The spirits of the woods have decided to test your wits in a magic-infused dungeon. The dungeon consists of $n$ doors connecting two distinct rooms, each door marked by a glowing symbol on both sides (to simplify, each symbol is a number from 1ドル$ to $n$). Each room is shrouded in complete darkness, making you unable to see anything other than the symbols. You enter the dungeon through a magic door that disappears upon entry, and the sage waits for you after door $n$.
At the beginning of your quest, as well as every time you pass through a door, you see the symbols of all the doors that lead to and from the room which you are in. You also need to be quick of course, as the forces of Ganondorf do not wait. Going through doors a total of over 5ドル \cdot n$ times will be too slow and will cause Hyrule to fall to ruin!
This is an interactive problem. Your submission will be run against an interactor, which reads the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:
The interactor first sends one line with an integer $n$ (1ドル \leq n \leq 1000$), the number of doors in the dungeon (of darkness). After that, the following process begins:
When you go through door $n,ドル the interaction will stop.
Make sure you flush the buffer after each write.
A testing tool is provided to help you develop your solution.
Walking through more than 5ドル \cdot n$ doors or walking through a door that does not exist in the current room will result in a wrong answer.
Additionally, it is guaranteed that there will always be a way to get to the sage from your current room.
3 2 1 2 1 1 2 1 2 2 2 3
1 1 2 3
5 3 1 2 3 2 1 3 3 1 2 3 3 2 4 5 1 4 3 2 4 5
1 3 2 4 4 5