아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Constellations

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

요약
평균 제곱 거리로 가장 가까운 두 별자리를 합치되 나이로 동점을 깨고, 합쳐질 때마다 새 별자리의 크기를 출력한다.
난이도

보통10점 중 6점

유형
유니온 파인드, 기하, 정렬
정답자
아직 제출이 없습니다

문제

Astrologists took a hard scientific look at their zodiac horoscope predictions and realised that their methodology doesn't provide future insight better than chance. Instead of looking inwards they blame the stars and historical construction of constellations for their inability to predict the future. They're testing out a new way of constructing constellations that will renew their powers of future-sight.

They need your help to implement their iterative constellation creation system. Initially every star represents its own constellation. In every step you should merge two constellations into one, by picking the constellations that are closest to each other. The distance between two constellations AA and BB is defined as the average squared Euclidean distance of pairs of stars from each constellation:

d(A,B)=1∣A∣∣B∣∑_a∈A∑_b∈B∣∣a−b∣∣2. d(A, B) = \frac{1}{|A||B|}\sum\_{a\in A}\sum\_{b\in B}||a-b||^2.

If multiple pairs have the same distance you should merge older constellations first. When comparing two pairs of constellations that could be merged, first compare the distances between constellations. If both pairs are at exactly the same distance, compare them by the age of the older constellation in a pair. If there is still a tie, compare them by the age of the newer constellation in a pair. A constellation's age is defined by the time when it was formed with the last merge, or in case of single-star constellations by the age of the star. The stars in the input are listed from oldest to youngest.

입력

The first line contains NN, the number of stars. The next NN lines contain coordinates of stars with two space-separated integers X_iX\_i and Y_iY\_i.

출력

After every step of the described constellation creation system, print out the size of the newly created constellation. You should output N−1N-1 lines.

제한

  • 2≤N≤20002 \leq N \leq 2000
  • −1000≤X_i,Y_i≤1000-1000 \leq X\_i, Y\_i \leq 1000 for all 1≤i≤N1 \leq i \leq N
  • All pairs X_iX\_i, Y_iY\_i are unique since it's physically impossible for two stars to lie on the same point.

예제3

  1. 예제 1

    입력
    3
    0 0
    -1 0
    10 10
    
    예상 출력
    2
    3
    
  2. 예제 2

    입력
    4
    0 0
    0 -1
    0 1
    0 2
    
    예상 출력
    2
    2
    4
    
  3. 예제 3

    입력
    4
    0 0
    0 1
    0 -1
    0 2
    
    예상 출력
    2
    3
    4