#P14634. [2018 KAIST RUN Fall] Voronoi Diagram Returns

[2018 KAIST RUN Fall] Voronoi Diagram Returns

题目描述

:::align{center}

Voronoi Diagram of size 4. :::

In the 2-dimensional Cartesian coordinate system, we define the Voronoi Diagram\textbf{Voronoi Diagram} of a non-empty set of points SS, as a diagram that divides the plane by the criteria "which point in the set SS is closest in this location?". More precisely, the Voronoi diagram of a given non-empty point set {P1,P2,,Pn}\{P_1, P_2, \cdots, P_n\} is a collection of regions\textbf{regions}: A point KK is included in region ii if and only if d(Pi,K)d(Pj,K)d(P_i, K) \le d(P_j, K) holds for all 1jn1 \le j \le n, where d(X,Y)d(X, Y) denotes the Euclidean distance between point XX and YY.

For example, in the picture above, every location over the plane is colored by the closest point with such location. The points which belongs to a single region is colored by a light color indicating a region, and the points which belongs to more than one region forms lines and points colored black.

There is an algorithm which computes the Voronoi Diagram in O(nlog(n))O(n \log(n)), but it is infamous to be very complicated and hard. In fact, we are lenient problem setters, so we set n2000n \leq 2000, which means you can solve this task with slower Voronoi Diagram algorithms!

In this task, you should solve the point query problem\textbf{point query problem} in Voronoi diagram: in the Voronoi diagram constructed with the set of points {P1,P2,,Pn}\{P_1, P_2, \cdots, P_n\}, you should determine which region(s) the point belongs in. More precisely, you will be given qq queries of points. For each query point, you should determine the following:

  • If it's not included in any region, output NONE\texttt{NONE}.
  • If it's included in exactly one region, output REGION X\texttt{REGION X}, where X\texttt{X} is the index of such region.
  • If it's included in exactly two regions, output LINE X Y\texttt{LINE X Y}, where X\texttt{X} and Y\texttt{Y} (X\texttt{X} << Y\texttt{Y}) are the indices of such two regions.
  • If it's included in three or more regions, output POINT\texttt{POINT}.

输入格式

In the first line, the number of points consisting Voronoi diagram nn, and the number of queries qq are given. (3n2 000,1q250 0003 \le n \le 2\ 000, 1 \le q \le 250\ 000)

In the iith line of next nn lines, two integers indicating xx and yy co-ordinate of PiP_i are given. These are the points consisting the Voronoi diagram. All nn points are distinct. (x,y104|x|, |y| \le 10^4)

In the jjth line of next qq lines, two integers indicating xx and yy co-ordinate of QjQ_j are given. For each point QjQ_j, you should determine in which region(s) the given point belongs to. (x,y104|x|, |y| \le 10^4)

输出格式

Output consists of qq lines. In the jjth line, you should print one of following:

  • If QjQ_j is not included in any region, output NONE\texttt{NONE}.
  • If QjQ_j is included in exactly one region, output REGION X\texttt{REGION X}, where X\texttt{X} is the index of such region.
  • If QjQ_j is included in exactly two regions, output LINE X Y\texttt{LINE X Y}, where X\texttt{X} and Y\texttt{Y} (X\texttt{X} << Y\texttt{Y}) are the indices of such two regions.
  • If QjQ_j is included in three or more regions, output POINT\texttt{POINT}.
4 3
-5 0
0 5
3 4
1 -6
-2 2
0 0
2 2
LINE 1 2
POINT
REGION 3

提示

Example is illustrated as diagram above.