#P6641. [CCO 2020] A Game with Grundy

[CCO 2020] A Game with Grundy

Description

All discussions in this problem take place on the Cartesian coordinate plane.

There are NN people. Each person has a field of view, and each person is located at (xi,0)(x_i,0).

A field of view can be modeled as an angle.

Note that the two rays that form the angle are not included in the field of view.

Now, you may stand at (a,Y)(a,Y), where LaRL \le a \le R.

For each ii (0iN)(0 \le i \le N), find how many positions you can stand at such that you are inside the field of view of at most ii people.

Input Format

The first line contains an integer NN.

The second line contains three integers L,R,YL, R, Y.

The next NN lines each contain three integers xi,vi,hix_i, v_i, h_i. Here, viv_i and hih_i mean that the slopes of the two rays forming the angle are vihi\frac{v_i}{h_i} and vihi\frac{-v_i}{h_i}, and one endpoint is at (xi,0)(x_i,0).

Output Format

There are N+1N+1 lines, each containing one integer. The value on line ii indicates the number of positions where you can stand such that you are inside the field of view of at most i1i-1 people.

3
-7 7 3
0 2 3
-4 2 1
3 3 1
5
12
15
15

Hint

Sample Explanation

Subtasks

This problem uses bundled testdata.

  • Subtask 1 (6060 points): It is guaranteed that 106LR106-10^6 \le L \le R \le 10^6.
  • Subtask 2 (4040 points): No additional constraints.

For 100%100\% of the testdata, it is guaranteed that 1N1051 \le N \le 10^5, 109LR109-10^9 \le L \le R \le 10^9, 1Y1061 \le Y \le 10^6, 1xiR1 \le x_i \le R, and 1vi,hi1001 \le v_i, h_i \le 100.

Notes

This problem is translated from Canadian Computing Olympiad 2020 Day 1 T1 A Game with Grundy.

Translated by ChatGPT 5