#P2093. [国家集训队] JZPFAR

[国家集训队] JZPFAR

Description

There are nn points on the plane. There are mm queries. In each query, given a point (px,py)(px, py) and an integer kk, output the index of the kk-th farthest point from (px,py)(px, py) among the nn points. If two (or more) points have the same distance to (px,py)(px, py), then the point with the smaller index is considered farther.

Input Format

The first line contains an integer nn, the number of points. The next nn lines each contain two integers xi,yix_i, y_i, the coordinates of the nn points. The indices of the points follow the input order and are 1n1\ldots n. The next line contains an integer mm, the number of queries. The next mm lines each contain three integers pxi,pyi,kipx_i, py_i, k_i, describing a query.

Output Format

Output mm lines. Each line contains one integer, the answer to the corresponding query.

3
0 0
0 1
0 2
3
1 1 2
0 0 3
0 1 1
3
1
1

Hint

  • Constraints and Notes.
    • In 50%50\% of the testdata, the coordinates of the nn points are randomly distributed within some range.
    • In 100%100\% of the testdata, 1n1051\le n\le 10^5, 1m1041\le m\le 10^4, 1k201\le k\le 20, 109xi,yi,pxi,pyi109-10^9\le x_i, y_i, px_i, py_i\le 10^9. Any two points among the nn points have different coordinates. The coordinates of the query points in the mm queries are randomly distributed within some range.

Translated by ChatGPT 5