Transport Pluses
시간 제한2초메모리 제한2048 MB
직선 이동과, 중심의 행이나 열을 공유하는 모든 점을 연결하는 n개의 이동 플러스를 이용해 두 점 사이를 이동하는 최소 에너지와 경로를 구한다.
문제
Cambeet lives on a plane. He wants to travel from his home located at point to the exhibition located at point . There are two ways to travel on the plane, and each consumes energy.
First, one can move along a segment between two points. The energy required for such travel is equal to the length of the segment: moving from point to points consumes units of energy.
Second, there are transport pluses on the plane, numbered by integers from to . Plus is centered at point and connects all points with or : one can instantly travel from any such point to any other such point, they just have to input the coordinates in a mobile app. Each use of any plus consumes units of energy.
Cambeet can use any ways of travel in any order. Help him find a path that will require the minimum total amount of energy.
입력
The first line contains two integers and : the number of transport pluses and the energy consumed by every use of a plus (). The second line contains two integers and : the coordinates of Cambeet's home (). The third line contains two integers and : the coordinates of the exhibition (). Each of the next lines contains two integers and : the coordinates of the center of -th plus ().
All input data are integers. However, Cambeet can freely travel to points with any real coordinates.
출력
On the first line, print a real number: the total consumed energy. On the second line, print an integer : the number of moves in the path (). On each of the next lines, print three integers , and : the number of the plus being used and the coordinates of the next target. The value of can be zero, which means traveling along a segment, or an integer from to , which means using a plus with such number. The coordinates can be any real numbers from to . When using a plus, this plus must connect the current position and the next target. The path must end at .
You can print any path that requires the minimum total amount of energy. The answer will be considered correct if the total consumed energy differs from the minimum possible by at most .