#P9289. [ROI 2018] Quantum teleportation
[ROI 2018] Quantum teleportation
Background
Translated from ROI 2018 Day1 T4. Квантовая телепортация (Quantum teleportation)。
Problem Description
On a 2D Cartesian coordinate plane, there are CPUs numbered .
The position of each CPU can be represented by coordinates on the plane. CPU is located at , and CPU is located at . It is guaranteed that all CPUs are on integer grid points, and for each CPU with coordinates , it holds that and .
The time for CPU to transmit a piece of data to CPU via the bus is time units.
Find the minimum time needed to send the data from CPU to CPU , and output one valid plan.
Input Format
The first line contains three integers .
The next lines each contain two integers .
Output Format
The first line contains an integer , which denotes how many CPUs are visited in the fastest plan.
The second line contains integers, denoting the CPUs visited in order.
If there are multiple paths with the minimum time, output any one of them.
4 5 3
1 1
2 3
4 5
3
1 2 3
5 6 9
1 1
4 3
4 6
2 5
3 1
3 3
3 6
5 4
5 6
5
1 6 2 8 9
Hint
For all testdata, .
Constraints
| Subtask ID | Special Property | |
|---|---|---|
| None | ||
| There is only one CPU in each row and each column | ||
| None |
Translated by ChatGPT 5