CF1599D.Bubble Popping
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are N bubbles in a coordinate plane. Bubbles are so tiny that it can be assumed that each bubble is a point (Xi,Yi) .
Q 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 i -th finalist would like to place the stick in the direction of vector (dxi,dyi) , and plays the following game until Ki bubbles are popped. The game starts with finalist placing the stick in the direction of vector (dxi,dyi) , 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 Ki 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 N bubbles, so the games don't depend on the previous games.
输入格式
The first line contains one integer N — the number of bubbles. ( 1≤N≤105 )
Each of the next N lines contains two integers. The i -th line contains integers Xi and Yi — the coordinates of the i -th bubble. ( −109≤Xi,Yi≤109 , (Xi,Yi)=(Xj,Yj) for i=j )
The next line contains one integer Q — the number of finalists willing to play with the bubbles. ( 1≤Q≤105 )
Each of the next Q lines contains 3 integers. The i -th line contains integers dxi , dyi and Ki . ( −109≤dxi,dyi≤109 , 1≤Ki≤N )
输出格式
For each of the Q 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.