Transport Pluses

시간 제한2초메모리 제한2048 MB

요약
직선 이동과, 중심의 행이나 열을 공유하는 모든 점을 연결하는 n개의 이동 플러스를 이용해 두 점 사이를 이동하는 최소 에너지와 경로를 구한다.
난이도

보통10점 중 7점

유형
그래프, 최단 경로, 기하, 구현
정답자
아직 제출이 없습니다

문제

Cambeet lives on a plane. He wants to travel from his home located at point (x_h,y_h)(x\_{\mathrm{h}}, y\_{\mathrm{h}}) to the exhibition located at point (x_e,y_e)(x\_{\mathrm{e}}, y\_{\mathrm{e}}). 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 (x_a,y_a)(x\_{\mathrm{a}}, y\_{\mathrm{a}}) to points (x_b,y_b)(x\_{\mathrm{b}}, y\_{\mathrm{b}}) consumes ∣x_b−x_a∣2+∣y_b−y_a∣2\displaystyle \sqrt{\left|x\_{\mathrm{b}} - x\_{\mathrm{a}}\right|^2 + \left|y\_{\mathrm{b}} - y\_{\mathrm{a}}\right|^2} units of energy.

Second, there are nn transport pluses on the plane, numbered by integers from 11 to nn. Plus ii is centered at point (x_i,y_i)(x\_i, y\_i) and connects all points with x=x_ix = x\_i or y=y_iy = y\_i: 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 tt 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 nn and tt: the number of transport pluses and the energy consumed by every use of a plus (0≤n,t≤1000 \le n, t \le 100). The second line contains two integers x_hx\_{\mathrm{h}} and y_hy\_{\mathrm{h}}: the coordinates of Cambeet's home (0≤x_h,y_h≤1000 \le x\_{\mathrm{h}}, y\_{\mathrm{h}} \le 100). The third line contains two integers x_ex\_{\mathrm{e}} and y_ey\_{\mathrm{e}}: the coordinates of the exhibition (0≤x_e,y_e≤1000 \le x\_{\mathrm{e}}, y\_{\mathrm{e}} \le 100). Each of the next nn lines contains two integers x_ix\_i and y_iy\_i: the coordinates of the center of ii-th plus (0≤x_i,y_i≤1000 \le x\_i, y\_i \le 100).

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 kk: the number of moves in the path (0≤k≤10,0000 \le k \le 10\\,000). On each of the next kk lines, print three integers p_jp\_j, x_jx\_j and y_jy\_j: the number of the plus being used and the coordinates of the next target. The value of p_jp\_j can be zero, which means traveling along a segment, or an integer from 11 to nn, which means using a plus with such number. The coordinates can be any real numbers from 00 to 100100. When using a plus, this plus must connect the current position and the next target. The path must end at (x_e,y_e)(x\_{\mathrm{e}}, y\_{\mathrm{e}}).

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 10−310^{-3}.

예제2

  1. 예제 1

    입력
    1 2
    1 1
    5 3
    6 2
    
    예상 출력
    4.000000
    4
    0 1 1.67
    0 1 2
    1 5 2
    0 5 3
    
  2. 예제 2

    입력
    2 1
    1 1
    6 1
    1 3
    6 3
    
    예상 출력
    2.0
    2
    1 5 3
    2 6 1