|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||37||21||20||62.500%|
Space pirate Captain Krys has recently acquired a map of the artificial and highly secure planet Alpha-Zet which he has been planning to raid for ages. It turns out the whole planet is built on a 2D plane with modules that serve as one room each. There is exactly one module at every pair of integer coordinates and modules are exactly 1 × 1 units big. Every module is bidirectionally connected to at least one adjacent module. Also, for any two modules there exists exactly one path between them. All in all the modules create a rectangular maze without any loops.
On the map Captain Krys has marked several modules he wants to visit in exactly the marked order. What he intends to do there is none of your business, but he promises you a fortune if you determine the number of modules he has to walk through along the route (since there are no loops he will always take the direct route from one marked module to the next). The first marked module indicates where he starts his journey, the last where he wants to finish.
Figure A.1: Illustration of Sample Input 2
The input consists of:
It is guaranteed that the maze itself is enclosed. Furthermore it is guaranteed that exactly one path exists between any two modules.
Output one integer, the number of modules Captain Krys has to travel through if he follows the route in the exact order given in the input.
2 6 _ _ _ _ _ _ | _ _ _ _ _| |_ _ _ _ _ _| 5 1 5 1 1 1 6 1 1 1 5
5 5 _ _ _ _ _ |_ _ |_ | | _| | _| | |_ _| | | _ _ | |_|_ _ _|_| 7 4 4 1 4 3 1 4 5 1 2 2 2 5 4