Animesh decides to settle down
InterviewTime limit1sMemory limit1024 MB
Given n convex polygons, find the area of the region that lies inside all of them.
- Level
Medium5 of 10
- Topics
- Geometry, Implementation
- Solved
- No attempts yet
Problem
After trying his luck in programming contests, Animesh has decided to accept his fate and settle down the good old-fashioned way. He has decided to own a farm and be a shepherd. He knows of n grass varieties, each of which grows in a convex polygon area. Some of these polygons may intersect each other. Each grass is lush green and nutritious, and he cannot make up his mind on where he should settle.
His friend Malvika, a long time shepherd herself (this is the other Malvika), suggested that he buy a piece of land where he can find all the n grass varieties, so that his sheep will be fat and produce lots of wool. Animesh liked the idea and wants to buy as much of such a pasture as possible. However, being short on money, he decided to be judicious, and only buy land which is covered by all the n grasses. That is, he would not buy even a bit of land which isn't part of all n of the grassy polygons. Can you please help in finding out the maximum area of land he can buy?
Input
The first line contains an integer n, the number of polygons.
Then the next lines describe the n polygons. The description of the i-th polygon is as follows.
The first line contains a single integer c, the number of points in the polygon.
Each of the next c lines contains two space-separated integers x[j] and y[j], the x and y coordinates of the j-th point of the polygon. The points are given in anti-clockwise order.
Output
Output the answer on a separate line. The answer is considered correct if its absolute error is less than .
Constraints
Hint
Each region in this case is rectangular. You can check that the intersection of all three input rectangles is another rectangle with corners at (5,3), (15,3), (15,5), and (5,5). This is the place Animesh is going to settle in. The area of this rectangle is .