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

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

Finding Routers

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

요약
고른 지점에서 가장 가까운 라우터의 번호를 알려주는 질의를 최대 q번 사용해 일직선 위 n개 라우터의 위치를 모두 알아낸다.
난이도

보통10점 중 6점

유형
이분 탐색, 구현
정답자
아직 제출이 없습니다

문제

There is a street of length ll meters stretching from left to right, with nn small routers occupying various distinct positions along it. The origin is defined to be the leftmost point of the street. The routers are labelled 00 to n−1n-1 from left to right, and router ii is placed p\[i]p\[i] meters away from the origin.

It is guaranteed that router 00 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 nn 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 xx 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 qq times. Devise a strategy to find the positions of all the routers.

제한

  • p\[0]=0p\[0]=0
  • 0≤p\[i]≤l0 \leq p\[i] \leq l and p\[i]p\[i] is even. (for all 0≤i≤n−10 \leq i \leq n-1)
  • p\[i]<p\[i+1]p\[i] < p\[i+1] (for all 0≤i≤n−20 \leq i \leq n-2)

예제

이 문제는 공개된 예제가 없습니다.