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

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

Archipelago

면접 대비

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

요약
섬 n개의 좌표와 배의 이동 거리 d가 주어질 때, 길이 d 이하의 이동을 여러 번 이어서 도달할 수 있는 섬의 수가 많은 순서대로 섬을 나열한다.
난이도

보통10점 중 5점

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

문제

The company you work for, Boats to Get Out (BGO), has recently discovered a new archipelago that simply begs to become a new tourism hotspot. The islands are all extremely tiny, so there should be ample opportunity to base almost all transportation in the region on boats.

Unfortunately, the islands are so far out in the ocean that the standardized boat BGO provide is not able to reach any of them from the mainland; their boats can only hold enough fuel to travel a distance of dd kilometers. To access the archipelago at all hence require that an airport is built on one of the islands. But where should it be located?

The BGO boss has ordered you to list out all the islands in order from highest to lowest airport utility. The airport utility of an island is defined as the number of islands it is possible to reach by boat from that island using any number of intermediate stops on other islands for refuelling.

입력

The first line of input consists of two space-separated integers 1≤n<2,0001 \leq n < 2\\,000 and 1≤d<1061 \leq d < 10^6, where nn signify the number of islands and dd indicates how far a boat can travel in kilometers before it needs to refuel. The islands are named from 11 to nn. The next nn lines of input describes the location of the islands. The ithi^{\text{th}} such line contains two space-separated integers 0≤x_i<1070 \leq x\_i < 10^{7} and 0≤y_i<1070 \leq y\_i < 10^{7} which describe the coordinates of island ii.

출력

Output a single line containing nn space-separated integers indicating a ranking of the islands from highest to lowest airport utility. If there are multiple islands with the same utility, you may output them in any order as long as their airport utility is non-increasing.

예제2

  1. 예제 1

    입력
    7 3
    1 1
    3 2
    2 3
    4 2
    12 5
    13 7
    11 6
    
    예상 출력
    1 2 3 4 5 6 7
    
  2. 예제 2

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