luogu#P8463. 「REOI-1」深潜的第六兽
「REOI-1」深潜的第六兽
Background
"None of the 'Seventeen Beasts' can fly. Therefore, after they destroyed the earth, the floating continents could still remain suspended in the sky.
"However, only the 'Sixth Beast of Deep Diving' can, while its main body stays on the ground, still attack the floating continents. It has two abilities: 'Split Proliferation' and 'Rapid Growth'.
"The main body staying on the surface will split into tens of thousands of fragments, which then drift with the wind, waiting to accidentally float onto some floating island. After reaching an island, it will grow rapidly on the spot, and after about six to eight hours, it can occupy and destroy the entire island."
Problem Description
Now there is a 'Sixth Beast'. During one "Split Proliferation", it split into fragments. These fragments will fly straight upward. If one fragment encounters a floating island (for convenience of research, we treat it as a line segment in 2D space), it will quickly occupy it, split into two, and then fly straight upward again from the two ends of the floating island.
Fortunately, these are only some unimportant, most barren and uninhabited islands. But if we let them continue to wreak havoc, they will surely deal a devastating blow to those crucial floating islands. Therefore, the officers responsible for eliminating the 'Sixth Beast' decided to use the island they are on as a straight line to define the axis, and to use the direction of gravity as the positive direction of the axis. They monitored a total of floating islands, and determined the positions where those fragments split (the distance from the axis is regarded as infinite). They want to know: if we do nothing and let these fragments go, when they reach the officers' position, how many fragments will there finally be.
Note that if a floating island has equal to , then it is a point. After the 'Sixth Beast' occupies it, it will still split into two and fly upward from this point.
Hint: As physical objects, floating islands obviously do not overlap.
Brief statement:
In a Cartesian coordinate system, there are line segments parallel to the axis. The -th segment is the segment connecting and . Note that may equal , in which case the segment becomes a point.
On the line , there are points located at .
Now these points move downward gradually (the negative direction of the axis). If a point touches a segment, it splits into two, and the two new points continue moving downward from the two ends of the segment, respectively.
In particular, if the segment is a point, it splits into 2 at the same position.
Ask: after all initial points undergo the splits caused by the segments, how many points will finally fall onto the axis.
Input Format
The first line contains two integers and .
The next lines each contain three integers , , , describing the -coordinate of the left endpoint, the -coordinate of the right endpoint, and the -coordinate of the segment, respectively ().
The next line contains integers , where is the -coordinate of the -th fragment ().
Output Format
Output one integer , the number of fragments that finally land on the axis. The answer should be taken modulo .
2 2
1 3 2
2 6 1
3 5
5
Hint
Sample explanation:
Note that the positive direction of the axis is the direction of gravity. In the coordinate system, the fragment with -coordinate first falls onto the segment at , then splits into two and falls downward from and . The one at falls onto the segment at , splits into two and falls downward from and . The first fragment becomes fragments in total, landing at . The second fragment becomes fragments in total, landing at .
| Subtask | Special Constraints | Score |
|---|---|---|
| 1 | 10 | |
| 2 | 5 | |
| 3 | 35 | |
| 4 | 50 |
The subtasks of this problem are not bundled for testing.
For of the data, , and all numbers are non-negative integers.
Constraints:
Translated by ChatGPT 5