Waterloo 2017 Fall E - English

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type
2017 Fall Waterloo Local ACM Contest, Problem E

Vera has N rectangles. The i-th rectangle has corners (ai,bi) and (ci,di). Let U be the union of the N rectangles. The intersection of U and the line y=sx is composed of disjoint line segments (maybe degenerate ones). Let f(s) be the sum of the lengths of these line segments or be zero if the intersection is empty.

Given integers L and R, let S=s=LRf(s). It can be seen that S=V2 for some integer V. Compute the value of V.

Input

Line 1 contains integers N,L,R (1N103,2×108L<R2×108).

N lines follow. The i-th line contains integers ai,bi,ci,di (108ai<ci108,108bi<di108).

Output

Print one line with one integer, the value of V.

Sample Input

Copy
3 -1 3
-2 -1 0 2
-1 0 1 1
1 -2 2 -1

Sample Output

Copy
7

Note

The below figure illustrates the first example when s=0. f(0) is the sum of the lengths of the two thick blue line segments. Note that S=729.899.


Comments

There are no comments at the moment.