Area of Rectangles.


Submit solution

Points: 100 (partial)
Time limit: 2.0s
Memory limit: 512M

Author:
Problem type

Dados n rectángulos, tu tarea es determinar el área total de su unión.

Entrada

La primera línea tiene un entero n: el número de rectángulos. Después, hay n líneas que describen los rectángulos. Cada línea tiene cuatro enteros x_1, y_1, x_2 e y_2: un rectángulo comienza en el punto (x_1,y_1) y termina en el punto (x_2,y_2).

Salida

Imprime el área total cubierta por los rectángulos.

Restricciones

  • 1 \leq n \leq 10^5
  • -10^6 \leq x_1 < x_2 \leq 10^6
  • -10^6 \leq y_1 < y_2 \leq 10^6

Ejemplo de Entrada

3
1 3 4 5
3 1 7 4
5 3 8 6

Ejemplo de Salida

24

Comments

There are no comments at the moment.