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

Сборники > Data Structures > задача:


51072 - Castle on chessboard

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

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

• 51062 - Fish Pond II
• 51067 - Jumping frog
• 51080 - Deepest Point
• 51079 - Key person - 2
• 51021 - Number of Nodes
• 51044 - Number of Trees
• 51010 - Max Sequential Sum
• 51086 - Top popular student
• 51072 - Castle on chessboard
• 51015 - Student Scholarships
• 51082 - Sum is equal to K - 1
• 51020 - Number of nodes removed
• 51023 - Preparing Keyword Index
• 51075 - Shortest Path for Bishop
• 50774 - Hot Potato
• 50688 - Epoka Furgon
• 50750 - Service Time - 2

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

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

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

Castle on chessboard

Question: You have some pieces (blocked cells) on a chessboard and a castle. Show at least in have many moves the castle can move to the given destination.

Input specification: You will be first given 4 integers (x,y) coordinates of starting and destination cells. Then you will be given an integer (n) the number of blocked cells. Each of the following n lines will provide two integers (x,y) coordinates of the blocked cells.

Output specification: Show one integer, the length of shortest path. Show -1, if there is no path.

Sample Input I
1 1 4 5
4
3 3
3 5
4 3
3 4
Sample Input II
1 1 4 5
5
1 4
4 4
5 5
3 4
2 4
Sample Output I
3
Sample Output II
4



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

www.contester.ru