Area - MarisaOJ: Marisa Online Judge

Area

Time limit: 1000 ms
Memory limit: 256 MB
Given $n$ rectangles on a two-dimensional coordinate grid. The rectangles have coordinates of the bottom-left corner as $(x_1, y_1)$ and the top-right corner as $(x_2, y_2)$, with their sides parallel to either the x-axis or the y-axis. ### Input - The first line contains an integer $n$. - The next $n$ lines each contain four integers $x_1, y_1, x_2, y_2$, representing a rectangle with coordinates of the bottom-left corner as $(x_1, y_1)$ and the top-right corner as $(x_2, y_2)$. ### Output - Print an integer representing the total area covered by the rectangles. ### Constraints - $1 \leq n \leq 10^5$. - $1 \leq x_1, y_1, x_2, y_2 \leq 10^5$. ### Example Input: ``` 3 2 1 6 5 1 4 5 8 4 2 9 7 ``` Output: ``` 46 ```