#P16575. 古神线段树·改
古神线段树·改
Background
The Ancient God Segment Tree is too hard, and the problem setter could not solve it, so they modified it.
Problem Description
- A line is represented as , and it is guaranteed that .
- When a line appears, it lights up all integer points that satisfy:$$y \cdot (tx-sx) \cdot \big( (ty-sy)\cdot(x-sx) - (tx-sx)\cdot(y-sy) \big) \ge 0$$
- A point that has already been lit will not be turned off, and will not be lit a second time.
There are operations. An operation can be:
- Add a line.
- Query the number of lit points in a rectangular region.
Each test point contains multiple groups of testdata.
Input Format
The first line contains two positive integers , representing the test point ID and the number of testdata groups. In the sample, is the smallest test point ID that satisfies the corresponding property.
For each group of testdata:
-
The first line contains one positive integer , representing the number of operations.
-
The next lines each contain integers, describing an operation as follows:
1 sx sy tx ty: add a line.2 lx ly rx ry: query the number of lit points satisfying and .
Output Format
For each operation , output one number per line as the answer.
1 1
3
1 1 2 4 1
1 4 4 2 1
2 1 1 4 3
8
Hint
The input size of this problem is large. A fast input template is provided in the downloadable files.
For all data:
- .
- .
- , and .
- , .
::cute-table{tuack}
| Test Point ID | Special Property | ||
|---|---|---|---|
| A | |||
| B | |||
| ^ | C | ||
| D | |||
| None | |||
| ^ | |||
- Special Property A: It is guaranteed that $\lvert lx \rvert, \lvert rx \rvert, \lvert ly \rvert, \lvert ry \rvert \le 500$.
- Special Property B: It is guaranteed that .
- Special Property C: It is guaranteed that .
- Special Property D: It is guaranteed that .
Translated by ChatGPT 5