IMPC 2017 |
Старт: 27.мая.2017 в 09:25:00
Финиш: 27.мая.2017 в 13:00:00
Турнир завершён!
• Турнирная таблица
|
|
Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Maze solver
You are given a maze where the walls are encoded with
the numbers:
- 1: There is a wall at the top and it is blocked
- 2: Right of the cell is blocked
- 4: Bottom of the cell is blocked
- 8: Left of the cell is blocked
Thus, 12 means there are walls on the left and bottom
of the cell and the doors on the other two walls are open.
Question:
Write a program that reads a 2D array of integers,
and defines the shortest path from upper left corner
to the bottom right corner.
Input specification:
First, you will be given two numbers (n and m)
size of maze. Then, you will be given m numbers
in the following n lines where the numbers
are between 0 and 15 and 1 ≤ (n and m)
≤ 100.
Output specification:
Show one integer: minimum number of steps to reach.
Show minus 1 if there is no path.
Sample Input 1 |
Sample Input 2 |
6 5
11 9 1 5 7
8 6 10 13 3
10 11 8 3 10
14 8 6 12 2
13 4 3 11 10
13 5 6 12 6
|
3 4
11 9 5 7
12 4 5 3
13 5 5 6
|
Sample Output 1 |
Sample Output 2 |
12
|
6
|
Для отправки решений необходимо выполнить вход.
|