#P4122. Blocked Billboard
Blocked Billboard
Blocked Billboard
Bessie the cow loves to gaze at two enormous billboards advertising delicious cow feed products. However, her view may be partially obstructed by a large truck parked across the street. Given the positions of the two rectangular billboards and the rectangular truck, your task is to compute the total visible area of the billboards that is not blocked by the truck.
A rectangle is specified by its lower-left and upper-right coordinates, \( (x_1,y_1) \) and \( (x_2,y_2) \), respectively. Its area is calculated as:
[ \text{Area} = (x_2 - x_1) \times (y_2 - y_1) ]
If the truck overlaps with a billboard, only the region not covered by the truck is visible. The overlapping area between two rectangles (one billboard and the truck) can be determined using the intersection of their coordinates:
[ \text{Overlap Area} = \max(0, \min(x_2, x'_2) - \max(x_1, x'_1)) \times \max(0, \min(y_2, y'_2) - \max(y_1, y'_1)) ]
Compute the sum of the visible areas of both billboards after subtracting any area that is obscured by the truck.
inputFormat
The input consists of three lines:
- The first line contains four integers: \( x_1\; y_1\; x_2\; y_2 \) for the first billboard.
- The second line contains four integers for the second billboard.
- The third line contains four integers for the truck.
outputFormat
Output a single integer representing the total visible area of the two billboards.
sample
1 2 3 5
6 3 8 9
10 10 12 12
18