A859 | Paint by Rectangles--Platinum
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
After [her previous
artwork](http://usaco.org/index.php?page=viewproblem2&cpid=1094) was met with
critical acclaim, Bessie was offered a job designing painting sets. She
designs these paintings by choosing $1\le N\le 10^5$ 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.****
artwork](http://usaco.org/index.php?page=viewproblem2&cpid=1094) was met with
critical acclaim, Bessie was offered a job designing painting sets. She
designs these paintings by choosing $1\le N\le 10^5$ 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
$(x_1,y_1), (x_2,y_2)$ where $1\le x_1<x_2\le 2N$ and $1\le y_1<y_2\le 2N$.
$(x_1, y_1)$ and $(x_2, y_2)$ are the bottom left and top right corners of the
rectangle respectively.
It is guaranteed that all the $x_i$ form a permutation of $1\ldots 2N$, and
the same holds for all the $y_i$.
The next $N$ lines each contain the description of a rectangle in the form
$(x_1,y_1), (x_2,y_2)$ where $1\le x_1<x_2\le 2N$ and $1\le y_1<y_2\le 2N$.
$(x_1, y_1)$ and $(x_2, y_2)$ are the bottom left and top right corners of the
rectangle respectively.
It is guaranteed that all the $x_i$ form a permutation of $1\ldots 2N$, and
the same holds for all the $y_i$.
输出格式
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.

regions. The boundaries of all rectangles are connected, so this input would
satisfy the conditions of subtask 3.

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted