#P6146. [USACO20FEB] Help Yourself G
[USACO20FEB] Help Yourself G
Description
There are segments on a number line. The -th segment covers all real numbers from to (including and ).
Define the union of some segments as the set of all points that are covered by at least one segment.
Define the complexity of some segments as the number of connected components formed by the union of these segments.
Now Bessie wants to compute, for all subsets of the given segments (there are in total), the sum of their complexities, and output the result modulo .
You might have guessed that you need to help Bessie solve this problem. But unfortunately, you guessed wrong! In this problem, you are Bessie, and nobody will help you. It is all up to you.
Input Format
The first line contains an integer ().
The next lines each contain two integers , describing a segment. It is guaranteed that , and no two endpoints are at the same position.
Output Format
Output the required answer modulo .
3
1 6
2 3
4 5
8
Hint
Sample Explanation
The complexities of all non-empty subsets are as follows (clearly, the empty set has complexity ):
$$\{[1,6]\} \implies 1, \{[2,3]\} \implies 1, \{[4,5]\} \implies 1$$$$\{[1,6],[2,3]\} \implies 1, \{[1,6],[4,5]\} \implies 1, \{[2,3],[4,5]\} \implies 2$$So the answer is .
Subtasks
- Test points satisfy .
- Test points satisfy .
- Test points have no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号