AMPPZ in the times of disease

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

요약
평면 위 n개의 점을 k개의 비어 있지 않은 대학으로 나누되, 같은 대학 두 점 사이의 최대 거리가 서로 다른 대학 두 점 사이의 최소 거리보다 작아야 한다.
난이도

어려움10점 중 8점

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

문제

Organizing AMPPZ in the times of pandemic is quite a challenge. As the Head Judge of Social Distancing, it is your job to ensure that participants keep a safe distance from each other. Since students from a single university are practically a family, you're mostly concerned with the distance between pairs of students from different universities. Intuitively, you want the students from the same university to form a tight group, keeping a safe distance from all other such groups.

To formalize your intuition, you came up with the following rule: let AA denote the largest euclidean distance (standard distance on the plane) between two of students from the same university, and let BB denote the smallest euclidean distance between two students from different universities. Then your rule states that A<BA < B must hold.

All your guests accepted the guidelines, and upheld them throughout the event. However, there's a catch: after the competition ended, you were asked to prove that the social distancing rules were indeed respected. Everybody is already gone, and the only thing left is to try to use one of the group photos as a proof... problem is, you don't know which contestants were affiliated with which university! But since you know, that the social distancing rule was upheld, maybe you can recover the division into universities?

Knowing the positions of all students in the picture (described as points on the plane: the group photo was taken from above using a drone, as this was the angle from which the contestants looked the best.) and the number of universities, divide students into universities in a way that respects your social distancing rule. Every university has to have at least one student; moreover, you can assume that the solution always exists.

입력

The first line of input contains the number of test cases zz (1≤z≤100,0001 \leq z \leq 100\\,000). The descriptions of the test cases follow.

The first line of a test case contains two integers nn, kk (2≤n≤2,000,0002 \leq n \leq 2\\,000\\,000, 2≤k≤min⁡(n,20)2 \leq k \leq \min(n, 20)), denoting the number of students and the number of universities, respectively.

The next nn lines describe the positions of the students. Each contains two integers x_ix\_i, y_iy\_i (0≤x_i,y_i<1090 \leq x\_i, y\_i < 10^9), denoting the coordinates of the ii-th student. No two students stand in exactly the same place.

The total number of students across all test cases does not exceed 10710^7.

출력

For every test case, output nn integers c_1,⋯ ,c_nc\_1, \cdots, c\_n (1≤c_i≤k1 \leq c\_i \leq k): a division of students into universities that satisfies the social distancing rule. If there are multiple solutions, you can output any of them.

힌트

Blank lines in the example input were added for readability. They are not present in the real input files.

Below we show the sample test cases together with possible correct answers.

예제1

  1. 예제 1

    입력
    3
    3 2
    0 0
    0 1
    0 3
    4 4
    0 0
    0 1
    1 0
    1 1
    8 3
    3 1
    4 1
    1 6
    2 6
    6 5
    6 7
    3 2
    4 2
    
    예상 출력
    1 1 2
    4 1 3 2
    2 2 1 1 3 3 2 2