CF1599D.Bubble Popping

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are NN bubbles in a coordinate plane. Bubbles are so tiny that it can be assumed that each bubble is a point (Xi,Yi)(X_i, Y_i) .

QQ Bubble Cup finalists plan to play with the bubbles. Each finalist would link to use infinitely long Bubble Cup stick to pop some bubbles. The ii -th finalist would like to place the stick in the direction of vector (dxi,dyi)(dxi, dyi) , and plays the following game until KiK_i bubbles are popped. The game starts with finalist placing the stick in the direction of vector (dxi,dyi)(dx_i, dy_i) , and sweeping it from the infinity to the left until it hits some bubble, which is immediately popped. It is guaranteed that only one bubble will be hit in this step. After that the finalist starts rotating the stick in the counter clockwise direction with the center of rotation in point where the previous bubble was popped. When the next bubble is hit, it is immediately popped and becomes the new center of rotation. The process continues until KiK_i bubbles have been popped. It is guaranteed that the stick won't hit two bubbles simultaneously in this process.

For each finalist find which bubble would be popped the last. Note that each game starts with the configuration of all NN bubbles, so the games don't depend on the previous games.

输入格式

The first line contains one integer NN — the number of bubbles. ( 1N1051 \leq N \leq 10^5 )

Each of the next NN lines contains two integers. The ii -th line contains integers XiX_i and YiY_i — the coordinates of the ii -th bubble. ( 109Xi,Yi109-10^9 \leq X_i, Y_i \leq 10^9 , (Xi,Yi)(Xj,Yj)(X_i, Y_i) \neq (X_j, Y_j) for iji \neq j )

The next line contains one integer QQ — the number of finalists willing to play with the bubbles. ( 1Q1051 \leq Q \leq 10^5 )

Each of the next Q lines contains 3 integers. The ii -th line contains integers dxidx_i , dyidy_i and KiK_i . ( 109dxi,dyi109-10^9 \leq dx_i, dy_i \leq 10^9 , 1KiN1 \leq K_i \leq N )

输出格式

For each of the QQ finalists, print the index of the bubble which would be popped last, in the separate line.

输入输出样例

  • 输入#1

    4
    0 0
    1 0
    0 1
    1 1
    2
    1 -1 3
    -1 1 4

    输出#1

    4
    2
  • 输入#2

    4
    1 1
    2 2
    7 1
    1 7
    3
    2 2 1
    1 -5 4
    -6 5 3

    输出#2

    3
    2
    3

说明/提示

There are two finalists willing to play with the bubbles. If the first finalist plays with the bubbles, then the bubbles at coordinates (0, 0), (1, 0) and (1, 1) would be popped in that order. Their indexes are 1, 2 and 4, so the answer is 4. If the second finalist plays with the bubbles, then the bubbles at coordinates (1, 1), (0, 1), (0, 0) and (1, 0) would be popped in that order, so the answer is 2.

Visualization: link.

首页