Easter Bunnies 2D

Problem #261

Tags: arrays binary puzzle

Who solved this?

No translations... yet

Here comes the next problem from Mathias Kern aka gardengnome - thanks once more!

After saying goodbye to the 1D Easter Bunnies, you move on to their neighbours the 2D Easter Bunnies (?!?). And this time there are only about 100 of them. That’s more like it.

They are clearly related as once more each bunny delivers, or steals, Easter eggs, this time to the grid positions within a rectangular area described by (x1, y1, x2, y2). The area (1, 1, 2, 2), for instance, contains the 4 cells (1, 1), (1, 2), (2, 1) and (2, 2). If the first bunny delivers to the area (1, 1, 2, 2), there would be 4 Easter eggs. If the second bunny delivers to the area (2, 2, 3, 3), then it would first steal the egg from (2, 2) but then add new eggs to (2, 3), (3, 2) and (3, 3), in other words there would be 6 eggs overall.

You are given N tuples x1, y1, x2, y2 describing the rectangular areas of the N Easter bunnies. After they all have delivered and/or stolen Easter eggs, how many Easter eggs are remaining there? Coordinates won't exceed 1000.

Input data shall have N - number of bunnies in the first line.
Next lines (exactly N) give x1 y1 x2 y2 for each bunny's rectangle.

Answer should be a single value - number of eggs planted in the field after all the bunnies did their work!

Example

input:
6
5 16 19 20
13 7 17 10
6 1 16 2
9 11 17 17
6 6 14 11
5 6 19 9

answer:
152

Solutions for this task are intentionally hidden - please look instead into solutions for the advanced version... When you solve it :)

You need to login to get test data and submit solution.