Finding Routers

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

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 n1n-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
  • 0p\[i]l0 \leq p\[i] \leq l and p\[i]p\[i] is even. (for all 0in10 \leq i \leq n-1)
  • p\[i]<p\[i+1]p\[i] < p\[i+1] (for all 0in20 \leq i \leq n-2)