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

Турниры > CEN303_2016Questions > задача:


HW091. 51061 - The Longest Path

CEN303_2016Questions

Старт: 28.окт.2016 в 17:00:00
Финиш: 01.ноя.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

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

Задачи турнира

• HW052. 51020 - Number of nodes r...
• HW061. 50448 - Paint Buckets
• HW062. 51021 - Number of Nodes
• HW071. 51042 - The most frequent ...
• HW072. 51043 - Genome Sequencing
• HW081. 51044 - Number of Trees
• HW082. 50699 - Fighting Vampires
• HW083. 50671 - Phalanx
• HW091. 51061 - The Longest Path
• HW101. 50682 - Hotel Durres
• HW102. 51067 - Jumping frog
• HW111. 50506 - The Biggest Island
• HW112. 50698 - Ayran Delivery
• PE11. 51023 - Preparing Keyword I...
• PE12. 50835 - Club Presidency
• PE13. 51024 - Total Stock Price
• PE14. 50998 - CEN112 Homework, ...

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

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

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

The Longest Path

Question: There is snake moving around the maze. And, it wants to travel as long as possible. The snake can use the same direction it currently has or it can change direction according to the values of the cells. The cell value is 0 means no change in direction. If there is number in the cell, the snake uses the cell value modulus 4 to decide for the new direction. The table on the right gives possible directions according to the value of the cell. So, the snake either keeps the current direction or changes the direction according to the given table. The journey ends if the snake hits to the border, or it hits to a visited cell. The default starting direction is Right.

Question: Write a program that defines the length of the longest path according to the given maze information.

Input specification: You will be given 3 integers in the beginning, the length of the square field (n) and the (x,y) coordinate of the starting position. Then you will be given a n-by-n matrix of integers where integers are between 0 and 1000 (mostly zeros) and 1 ≤ n ≤ 15.

Output specification: Show one integer.

Sample Input I
4 1 1
6 0 6 0
0 0 9 0
0 0 0 0
0 0 0 0
Sample Input II
4 1 1
6 0 6 6
0 0 9 0
0 0 0 0
0 0 0 0
Sample Output I
6
Sample Output II
7

Explanation: Figure on the right, gives 4 possible paths for the question where Path in image (D) has the longest path (6).



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

www.contester.ru