Signal Flood
View as PDFThe central district of Neon City is covered by a swarm of emergency transmitters. Each transmitter floods an axis-aligned rectangular region of the ground with radio noise.
Your repair drone can only land in places receiving exactly simultaneous
broadcasts. After all
transmitters are active, determine the total area where
the signal strength is exactly
.
Model the district as the 2D -
plane. Each transmitter is described by the
coordinates of the lower-left and upper-right corners of its rectangular coverage
zone.
Input
The first line contains two integers and
.
Each of the next lines contains four integers
, describing
a rectangle with lower-left corner
and upper-right corner
.
Output
Output a single integer: the area covered by exactly transmitters.
Constraints
Example 1
Input
3 2
1 1 5 5
4 4 7 6
3 3 8 7
Output
8
Explanation
Exactly eight unit squares are covered by two transmitters.
Example 2
Input
4 1
0 0 2 3
2 0 4 3
1 1 3 2
0 3 4 4
Output
14
Explanation
The third rectangle overlaps one unit square from each of the first two rectangles.
Those two overlapped squares have coverage , so the remaining
units of area
have coverage exactly
.
Comments