100 atcoder#ABC047B. [ABC047B] すぬけ君の塗り絵 2 イージー
[ABC047B] すぬけ君の塗り絵 2 イージー
Score : points
Problem Statement
There is a rectangle in the -plane, with its lower left corner at and its upper right corner at . Each of its sides is parallel to the -axis or -axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted points into the rectangle. The coordinate of the -th () point was .
Then, he created an integer sequence of length , and for each , he painted some region within the rectangle black, as follows:
- If , he painted the region satisfying within the rectangle.
- If , he painted the region satisfying within the rectangle.
- If , he painted the region satisfying within the rectangle.
- If , he painted the region satisfying within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
- ()
- ()
- , (21:32, added), and are integers.
- () is or .
Input
The input is given from Standard Input in the following format:
Output
Print the area of the white region within the rectangle after Snuke finished painting.
5 4 2
2 1 1
3 3 4
9
The figure below shows the rectangle before Snuke starts painting.
First, as and , he paints the region satisfying within the rectangle:
Then, as and , he paints the region satisfying within the rectangle:
Now, the area of the white region within the rectangle is .
5 4 3
2 1 1
3 3 4
1 4 2
0
It is possible that the whole region within the rectangle is painted black.
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
64