Navigation
InterviewTime limit1sMemory limit1024 MB
Given N routes that pass through ordered intermediate points, find the route number with the smallest total Manhattan distance from start to end.
- Level
Easy2 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem

Unmatched technology in location-based services
Hyundai AutoEver's navigation software delivers safe and convenient travel. It is used in more than 70 countries and leads the global infotainment market.
Its navigation software offers a wide range of content and services, giving customers a richer mobility experience and new value.
Built on GIS and LBS technology, precise map data, and route search algorithms, its advanced navigation solutions help automakers expand overseas and lead the global market.
Customer first
Vehicle navigation
Hyundai AutoEver helps customers around the world drive to their destinations quickly and safely. Putting customers first is its core value.
Based on center communication, the system tracks the user's current position in real time and provides road traffic conditions, closed sections, and other information that affects traffic flow.
ICPC Sinchon was asked by Hyundai AutoEver to test vehicle navigation. The staff compared the performance of Hyundai AutoEver's OEM navigation with the other navigation systems from other companies. They confirmed that the OEM navigation finds a more efficient optimal route to the destination.
The team plans to send this experimental data to Hyundai AutoEver after SUAPC 2022 Summer ends. The data contains the following information.
- The start point and the end point
- For each navigation, the intermediate points that must be visited in order to go from to
The distance between two points is the Manhattan distance. That is, the distance between and is . The optimal route distances computed by the navigation systems are all different.
However, on the day of SUAPC 2022 Summer, a sudden computer failure mixed up the experimental values of the navigation systems. Before the contest ends, you are given the data for each navigation. Find which data belongs to the OEM navigation.
Input
The first line contains a positive integer , the number of navigation systems used in the experiment. ()
The second line contains four integers , , , , separated by spaces, which are the coordinates of the start point and the end point. ()
The following lines give the data for navigation 1 through navigation , in order. The input for each navigation is as follows.
- The first line contains , the number of intermediate points that must be visited in order. ()
- The next lines each contain two integers separated by a space, the and coordinates of the -th intermediate point . ()
Output
Print the number of the data set that belongs to the OEM navigation.