Tourism
InterviewTime limit1sMemory limit128 MB
Visit the given sights in order on a grid with extra northeast diagonals and minimize the total number of road segments traveled.
- Level
Medium4 of 10
- Topics
- Shortest path, Math
- Solved
- No attempts yet
Problem
A city has a grid of roads plus northeast diagonal moves (except on the north/east border). Visit sights in order starting at the first. Minimize the number of road segments traveled, counting repeats.
Input
Line 1: , , . Next lines: coordinates .
Output
Print the minimum number of road segments.