Problem E
The Dark Chambers of Chalmers
Languages
en
sv
You are on your way to the final competition of the Swedish Olympiad in Informatics, which is hosted at Chalmers Technical University. However, you have gotten lost in the university basement. Your sense of direction is not great, and what makes matters worse is the very strange design of the basement.
![\includegraphics[scale=0.6]{chalmers_dark_chambers.png}](/problems/chalmers/file/statement/en/img-0001.png)
The basement consists of
A path is a sequence of steps to adjacent rooms.
For some path
Since the app is quite slow, you only have time to check it
at most
(1.a) |
![\includegraphics[scale=0.8]{sample1.png}](/problems/chalmers/file/statement/en/img-0002.png)
() |
(1.b) |
![\includegraphics[scale=0.8]{sample2.png}](/problems/chalmers/file/statement/en/img-0003.png)
() |
Interaction
First, you get information about the room you are currently in. This will be given as a binary string of length five, where every character is “1” if you can go in a certain direction, and “0” otherwise. In order, the characters tell you if you can go up, right, down to the right, down to the left, and left. So the string 01001 means that you can go to the right and to the left, but in no other directions.
Then, you choose either to go to an adjacent room, or to use Campus Maps. To go to an adjacent room you write any of the strings “up”, “right”, “downright”, “downleft” or “left”. Then you get information about the new room you are in, according to the same format as above.
To use the app you write “app”.
The app will then calculate the length of the shortest path
from where you are to the goal that uses as few staircases as
possible. Since the app is very sensitive to Integer Overflows,
it will crash if this length exceeds
When you reach your destination, you should print out “here”, and your program should be terminated.
Make sure to flush the output after each query, otherwise you can get Time Limit Exceeded. In C++ this can be done using cout << flush; or fflush(stdout); in Python with stdout.flush(), and in Java with System.out.flush();.
Scoring
Your solution will be tested on a number of sample groups. To get points in a group your solution must pass all test cases in that group.
Group |
Point value |
Constraints |
|
|
|
|
|
|
|
|
|
|
|
Every room that is not on the lowest floor has two rooms directly below it. |
|
|
|
|
|
|
|
|
|
Read | Sample Interaction 1 | Write |
---|
11110
app
4
up
11110
right
10101
app
2
downright
10010
downleft
10000
app
0
here
Read | Sample Interaction 2 | Write |
---|
10001
app
6
up
10111
app
4
left
11111
left
11111
left
11110
downright
11001
here