#P8777. [蓝桥杯 2022 省 A] 扫描游戏

    ID: 9695 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>模拟计算几何2022排序蓝桥杯省赛

[蓝桥杯 2022 省 A] 扫描游戏

Problem Description

There is a stick OAOA rotating clockwise around the origin OO. At the beginning, it points straight upward (the positive direction of the YY axis). There are several objects on the plane. The coordinates of the ii-th object are (xi,yi)\left(x_{i}, y_{i}\right), and its value is ziz_{i}. When the stick sweeps over an object, the length of the stick instantly increases by ziz_{i}, and the object disappears instantly (if the tip of the stick just touches the object, it is also considered swept). If, after this increase, the stick additionally touches other objects, they are also removed in the same way (they are considered to disappear at the same time as the object above).

If we sort the objects by their disappearance time, then each object has a rank, and objects that disappear at the same time have the same rank. Please output the rank of each object. If an object will never disappear, output 1-1.

Input Format

The first line contains two integers nn and LL, separated by one space, representing the number of objects and the initial length of the stick.

The next nn lines each contain three integers xix_{i}, yiy_{i}, and ziz_{i}.

Note that (xi,yi)=(0,0)\left(x_{i}, y_{i}\right)=(0,0) may occur. Such points are considered to be touched immediately at the start.

Output Format

Output one line containing nn integers, with one space between adjacent integers, in order, representing the rank of each object.

5 2
0 1 1
0 3 2
4 3 5
6 8 1
-51 -33 2
1 1 3 4 -1

Hint

For 30%30\% of the testdata, 1n5001 \leq n \leq 500.

For 60%60\% of the testdata, 1n50001 \leq n \leq 5000.

For all testdata, 1n2×1051 \leq n \leq 2\times10^5, 109xi,yi109-10^{9} \leq x_{i}, y_{i} \leq 10^{9}, 1L,zi1091 \leq L, z_{i} \leq 10^{9}.

This is Problem H of Lanqiao Cup 2022 Provincial Contest Group A.

Translated by ChatGPT 5