A823.Paint by Rectangles--Platinum
NOI/NOI+/CTSC
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
After her previous
artwork was met with
critical acclaim, Bessie was offered a job designing painting sets. She
designs these paintings by choosing 1≤N≤105 axis-aligned rectangles
in the plane such that no two edges are collinear. The boundaries of these
rectangles define the boundaries of the painting's colored regions.
Still being an avant-garde artist, Bessie decides that the painting should
resemble a Holstein cow. More specifically, each region formed by the
rectangles is colored either black or white, no two adjacent regions have the
same color, and the region outside of all the rectangles is colored white.
After choosing the rectangles, Bessie would like you to output one of two
things based on a parameter T:
- If T=1, output the total number of regions.
- If T=2, output the number of white regions followed by the number of black regions.
Note: the time limit for this problem is 4s, twice the default.
输入格式
The first line contains N and T.
The next N lines each contain the description of a rectangle in the form
(x1,y1),(x2,y2) where 1≤x1<x2≤2N and 1≤y1<y2≤2N.
(x1,y1) and (x2,y2) are the bottom left and top right corners of the
rectangle respectively.
It is guaranteed that all the xi form a permutation of 1…2N, and
the same holds for all the yi.
输出格式
A single integer if T=1, otherwise two separated by spaces.
输入输出样例
输入#1
2 1 1 1 3 3 2 2 4 4
输出#1
4
说明/提示
There are two white regions and two black regions, for a total of four
regions. The boundaries of all rectangles are connected, so this input would
satisfy the conditions of subtask 3.