luogu#P8861. 线段
线段
Problem Description
There is an initially empty set of segments. You need to process queries. Each query is in one of the following three forms:
- Add a new segment .
- For all segments in the set that intersect with , modify each of them into its intersection with .
- Compute the sum of lengths of the intersections between and all segments in the set that intersect with .
Two segments and intersect if and only if . Their intersection is .
The length of a segment is .
In some test points, you need to perform these operations online.
Note: In this problem, a segment may degenerate into a single point.
Input Format
The first line contains two positive integers and , representing the number of operations and the forced online parameter.
The next lines each contain three positive integers , where indicates the operation type.
Let be the answer to the previous type query ( is initially ). Then the real values are $l_i = ( l_i' + type \times last ) \bmod ( 2 \times 10^5 + 1 )$, $r_i = ( r_i' + type \times last ) \bmod ( 2 \times 10^5 + 1 )$.
The data guarantees that .
Output Format
For each type query, output one line containing the answer.
9 0
1 1 5
1 6 8
1 2 3
3 3 8
2 4 6
1 5 9
2 2 7
3 2 7
3 3 6
4
4
2
Hint
Sample Explanation
The set of segments after each operation:
- After the first:
- After the second:
- After the third:
- After the fifth:
- After the sixth:
- After the seventh:
Constraints
Let be the numbers of queries with , respectively.
| Test Point ID | Special Property | ||||
|---|---|---|---|---|---|
| None | |||||
| All type operations are after all type operations | |||||
| None | |||||
For all data, , , , , , .
Translated by ChatGPT 5