IITWPC4E - Maggu’s Solar Panels
Summer is here and so is the season of powercuts, everybody here in IITK has installed there own solar panels over the roof. Now while setting panels, nobody cared of there panel was overlapping with others, the end result looks something likes the one shown below.
Clearly, a panel cannot produce electricity from the part where light does not fall. Our Maggu has been given the task of estimating the total electricity output from panels from Hall Office. This task is haunting him. Even Coder cannot do it alone, he needs your help. Assume that all panels produce the same power per unit area and that the area not directly under the sun does not produce any electricity.
You need to print the power that will be produced given the end points of rectangular panels and the power per unit area that panels produce.
Note : The sides of the panel will be parallel to the X-axis or Y-axis. Meaning, panels will never be tilted. Hence, a panel can be represented by 4 integers x, y, X and Y. Where (x,y) is the co-ordinate of the bottom left corner of the panel and (X,Y) is the co-ordinate of the top right corner of the panel.
First line contains two space separated integers N, number of solar panels and R, power per unit area. Next N lines contains the description of N panels. Each line containing 4 space separates integers x, y, X and Y respectively.
You need to output a single integer, the total power that can be generated.
-6 0 3 6
0 4 6 10
4 -2 9 6