CF1599D.Bubble Popping

NOI/NOI+/CTSC

通过率:0%

时间限制:2.50s

内存限制:256MB

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.

坐标平面上有 NN 个气泡。气泡非常微小,因此可将每个气泡视为一个点 (Xi,Yi)(X_i, Y_i)。

共有 QQ 名 Bubble Cup 决赛选手计划与这些气泡进行游戏。每名选手将使用一根无限长的 Bubble Cup 棒来戳破若干气泡。第 ii 名选手希望将棒的方向设定为向量 (dxi,dyi)(dx_i, dy_i),并执行如下游戏,直至戳破 KiK_i 个气泡为止:游戏开始时,选手将棒按向量 (dxi,dyi)(dx_i, dy_i) 的方向放置,并从无穷远处自左向右平移该棒,直到首次触碰到某个气泡——该气泡立即被戳破。题目保证此步骤中仅会触碰到一个气泡。随后,选手以刚被戳破的气泡所在位置为旋转中心,将棒逆时针旋转;当棒再次触碰到下一个气泡时,该气泡立即被戳破,并成为新的旋转中心。此过程持续进行,直至共戳破 KiK_i 个气泡为止。题目保证在此过程中,棒不会同时触碰到两个气泡。

对每名选手,请找出其游戏中最后一个被戳破的气泡。注意:每轮游戏均从全部 NN 个气泡的初始配置开始,因此各轮游戏相互独立,互不影响。

输入格式

The first line contains one integer NN — the number of bubbles. (1≤N≤1051 \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. (−109≤Xi,Yi≤109-10^9 \leq X_i, Y_i \leq 10^9, (Xi,Yi)≠(Xj,Yj)(X_i, Y_i) \neq (X_j, Y_j) for i≠ji \neq j)

The next line contains one integer QQ — the number of finalists willing to play with the bubbles. (1≤Q≤1051 \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. (−109≤dxi,dyi≤109-10^9 \leq dx_i, dy_i \leq 10^9, 1≤Ki≤N1 \leq K_i \leq N)

第一行包含一个整数 NN —— 泡泡的数量。(1≤N≤1051 \leq N \leq 10^5)

接下来的 NN 行,每行包含两个整数。第 ii 行包含整数 XiX_i 和 YiY_i —— 第 ii 个泡泡的坐标。(−109≤Xi,Yi≤109-10^9 \leq X_i, Y_i \leq 10^9,且当 i≠ji \neq j 时,(Xi,Yi)≠(Xj,Yj)(X_i, Y_i) \neq (X_j, Y_j))

下一行包含一个整数 QQ —— 愿意参与泡泡游戏的决赛选手人数。(1≤Q≤1051 \leq Q \leq 10^5)

接下来的 QQ 行,每行包含三个整数。第 ii 行包含整数 dxidx_i、dyidy_i 和 KiK_i。(−109≤dxi,dyi≤109-10^9 \leq dx_i, dy_i \leq 10^9,1≤Ki≤N1 \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.

对于每位 QQ 位决赛选手,分别输出最后被戳破的气泡的索引(每行一个)。

输入输出样例

  • 输入#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.

有两位决赛选手愿意玩泡泡游戏。如果第一位决赛选手玩泡泡,那么坐标为 (0,0)(0, 0)、(1,0)(1, 0) 和 (1,1)(1, 1) 的泡泡将按此顺序被戳破。它们的编号分别为 11、22 和 44,因此答案是 44。如果第二位决赛选手玩泡泡,那么坐标为 (1,1)(1, 1)、(0,1)(0, 1)、(0,0)(0, 0) 和 (1,0)(1, 0) 的泡泡将按此顺序被戳破,因此答案是 22。

示意图:link。

输入解题思路,AI测评打分。不知道怎么写?

首页