A11710 | Visible Black Areas
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Petya has a polygon consisting of $n$ vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the polygon is simple, that is, it doesn't have self-intersections and self-touches. All internal area of the polygon (borders are not included) was painted in black color by Petya.
Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.
Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.
Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
输入格式
The first line contain four integers $x_1, y_1, x_2, y_2$ ( $x_1 < x_2$ , $y_2 < y_1$ ) — the coordinates of top-left and bottom-right corners of the rectangular window.
The second line contains a single integer $n$ ( $4 \le n \le 15\,000$ ) — the number of vertices in Petya's polygon.
Each of the following $n$ lines contains two integers — the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.
All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed $15\,000$ .
The second line contains a single integer $n$ ( $4 \le n \le 15\,000$ ) — the number of vertices in Petya's polygon.
Each of the following $n$ lines contains two integers — the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.
All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed $15\,000$ .
输出格式
Print the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
输入输出样例
输入 #1
5 7 16 3 16 0 0 18 0 18 6 16 6 16 1 10 1 10 4 7 4 7 2 2 2 2 6 12 6 12 12 10 12 10 8 0 8
输出 #1
2
The example corresponds to the picture above.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted