Pasture 3

시간 제한1초메모리 제한1024 MB

요약
정수 좌표를 가진 N개의 말뚝과 철사 예산 M이 주어질 때, 서로 교차하지 않는 선분으로 최대 개수의 삼각형을 만들고 총 길이를 최소로 하는 선분 집합을 구한다.
난이도

어려움10점 중 8점

유형
기하, 그리디, 정렬, 조합론
정답자
아직 제출이 없습니다

문제

Farmer John has NN posts on his pasture. The pasture can be modeled as a coordinate plane where each post has integer coordinates.

John wants to connect the posts with wire segments that do not cross (in other words, the wire segments may only touch at their common endpoints) and form a number of triangular enclosures for his sheep. The sheep are fairly selfish, so each of them needs to be in a separate enclosure.

As the business is not going particularly well at the moment, John would like to use as litte wire as possible. Help him arrange the wire segments so that the total length of wire used is as small as possible, but he can accommodate the maximal number of sheep. John has a limited amount of wire and cannot use more than that.

입력

The first line contains NN, the number of posts on the pasture (3≤N≤10,0003 \le N \le 10\\,000), and the integer MM, the total length of wire that John has (1≤M≤10101 \le M \le 10^{10}). Each of the following NN lines contains two integers X_iX\_i and Y_iY\_i, the coordinates of one fencepost (−105≤X_i,Y_i≤105-10^5 \le X\_i, Y\_i \le 10^5). The posts are numbered 1…N1 \ldots N in the order of their appearance in the input.

출력

The first line should contain KK, the number of wire segments, and LL, the total length of wire spent. Each of the following KK lines should contain two integers AA and BB, indicating that one of the wire segments should connect the posts AA and BB. The total length of wire, LL, should be given with exactly 66 decimal digits.

예제1

  1. 예제 1

    입력
    4 19
    0 0
    0 3
    3 0
    4 3
    
    예상 출력
    5 17.404918
    1 2
    2 4
    4 3
    3 1
    2 3