Trapezoids
Time limit1sMemory limit128 MB
Pick the most pairwise disjoint trapezoids between two lines and count those optimal sets modulo 30013.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Sorting, Segment tree
- Solved
- No attempts yet
Problem
Consider two parallel horizontal lines. A trapezoid lies between these two lines, with two of its vertices on the upper line and the other two on the lower line. Denote the four vertices of by the -coordinates (upper left), (upper right), (lower left), and (lower right). Thus its top edge spans the interval and its bottom edge spans .
Two trapezoids are said to intersect if they share at least one point. A subset of the trapezoids is called independent if no two trapezoids in intersect.
Two trapezoids and do not intersect exactly when one lies entirely to the left of the other on both lines; that is, is to the left of and the two do not intersect if and only if and .
Determine the size of the largest independent set of trapezoids. Also determine how many different independent sets of that maximum size exist, modulo .
Input
The first line contains a single integer , the number of trapezoids. Each of the next lines contains four integers , , , and . No two trapezoids share a common vertex (corner).
Output
Print two numbers separated by a space on a single line: first, the size of the largest independent set; then, the number of different independent sets of maximum size, modulo .
Constraints
Hint
The picture below is not drawn to scale. The tops and bottoms of the trapezoids have been shifted up and down for visibility.
