Finding Routers
시간 제한1초메모리 제한1024 MB
고른 지점에서 가장 가까운 라우터의 번호를 알려주는 질의를 최대 q번 사용해 일직선 위 n개 라우터의 위치를 모두 알아낸다.
문제
There is a street of length meters stretching from left to right, with small routers occupying various distinct positions along it. The origin is defined to be the leftmost point of the street. The routers are labelled to from left to right, and router is placed meters away from the origin.
It is guaranteed that router is at the origin, and the distance in meters from each router to the origin is an even integer.
You wish to find out the position of each of the routers. As the routers are very small and difficult to spot from afar, you've decided to use the following procedure to find them:
- Place a detector on a spot that is meters away from the origin,
- Use the detector to find the label of the router closest to it. If there are two routers that are the same distance away from it, it will respond with the router with the smaller label.
You are allowed to use the detector at most times. Devise a strategy to find the positions of all the routers.
제한
- and is even. (for all )
- (for all )
예제
이 문제는 공개된 예제가 없습니다.