#C7612. Intersection Area of Rectangles
Intersection Area of Rectangles
Intersection Area of Rectangles
Calculate the area of intersection between two rectangles.
Each rectangle is defined by two opposite vertices. The first rectangle has vertices ((x_1, y_1)) and ((x_2, y_2)), and the second rectangle has vertices ((X_1, Y_1)) and ((X_2, Y_2)).
The area of intersection is computed by the formula: $$S = \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)}$$.
If the rectangles do not overlap, the result is 0.
inputFormat
The input consists of a single line with 8 integers: x1, y1, x2, y2, X1, Y1, X2, Y2. These represent the coordinates of the two rectangles, where (x1, y1) and (x2, y2) are the opposite vertices of the first rectangle and (X1, Y1) and (X2, Y2) are those of the second rectangle.
outputFormat
Output a single integer representing the area of the intersection of the two rectangles. If the rectangles do not intersect, output 0.## sample
1 1 3 3 2 2 4 4
1