HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303_2016Questions > problem:


PE22. 51072 - Castle on chessboard

CEN303_2016Questions

Start: Oct.28.2016 at 05:00:00 PM
Finish: Nov.01.2016 at 05:00:00 AM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 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, ...
• PE21. 51071 - Phalanx-2
• PE22. 51072 - Castle on chessb...
• RE1. 51079 - Key person - 2
• RE2. 51080 - Deepest Point

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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