ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Kovrov IT > задача:


51011 - Decoding the Path

Гость
• Вопросы к жюри (14)

Задачи сборника

• 50854 - Area of Triangle Revised
• 50520 - Filling a Matrix Randomly
• 50497 - Falling Bricks - Revisited
• 50847 - The first m trains to leave
• 50669 - Area of an Irregular Polygon
• 50860 - Number of Student Certificates
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51011 - Decoding the Path
• 51019 - Finding the hidden message
• 51002 - The most successful classes
• 50525 - Ordering Pizza
• 50342 - 100 Factorial
• 50524 - Elevator
• 50531 - File Decryption
• 50758 - National Elections - Revisited
• 50687 - Pascal Triangle - 2

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Decoding the Path

Question: You will be given a two dimensional matrix which contains the path from a starting point to the destination. The path starts from 1 and goes to the given destination coordinate by increasing all the time by 1 from one cell to its adjacent. Show the coordinates of the path from start to destination.
Note: 1) Assume that there exists at least one path from start to the destination. 2) There may be many paths from start to destination. You can show any of them. 3) Pay attention that there are also some paths from start which does not lead to destination.

Input specification: You will be given three integers in the beginning:

  • Size of the square matrix (n)
  • x and y coordinates of the destination
where 1 < n ≤ 100 and x and y are between 1 and n. Then, each of the following n lines contains n integers which are between -1 and +2e4.

Output specification: Show series of (x, y) coordinates starting from the 1 reaching to the destination. Place a -1 at the last line.

Sample Input
5 5 5
2 3 4 5 -1
1 -1 -1 6 -1
2 3 4 5 6
-1 4 -1 6 7
-1 5 6 7 8
Sample Output
1 2
1 3
2 3
2 4
2 5
3 5
4 5
5 5
-1



Для отправки решений необходимо выполнить вход.

www.contester.ru