Problem 2: Overplanting (Bronze) [Brian Dean, 2012]
Farmer John has purchased a new machine that is capable of planting grass
within any rectangular region of his farm that is "axially aligned" (i.e.,
with vertical and horizontal sides). Unfortunately, the machine
malfunctions one day and plants grass in not one, but N (1 <= N <= 10)
different rectangular regions, some of which may even overlap.
Given the rectangular regions planted with grass, please help FJ compute
the total area in his farm that is now covered with grass.
农夫约翰购买了一台新机器,该机器能够在其农场的任何“轴向对齐”(即具有垂直和水平边)的矩形区域内种草。
不幸的是,这台机器有一天出了故障,并在 N 个不同的矩形区域内进行了种草工作,其中一些区域可能会有重叠。
给定机器工作的具体 N 个矩形区域,请你计算种上草的区域的总面积是多少。