CF962G.Visible Black Areas
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
佩佳有一个由 n 个顶点构成的多边形。该多边形的所有边均与坐标轴平行,且任意两条相邻边互相垂直。题目保证该多边形是简单多边形,即不存在自交或自接触。佩佳将该多边形的全部内部区域(不包含边界)涂成了黑色。
此外,佩佳还有一个矩形窗口,其位置由给定的坐标确定,他透过该窗口观察该多边形。该矩形窗口不可移动,其各边也与坐标轴平行。
图中蓝色表示多边形的边界,红色表示佩佳的窗口。本例的答案为 2。
请确定:透过该矩形窗口可见的、佩佳多边形内部的黑色连通区域的个数。
输入格式
The first line contain four integers x1,y1,x2,y2 (x1<x2, y2<y1) — the coordinates of top-left and bottom-right corners of the rectangular window.
The second line contains a single integer n (4≤n≤15000) — 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 15000.
第一行包含四个整数 x1,y1,x2,y2(满足 x1<x2,y2<y1),表示矩形窗口的左上角和右下角坐标。
第二行包含一个整数 n(4≤n≤15000),表示小彼得多边形的顶点数。
接下来的 n 行每行包含两个整数,表示小彼得多边形各顶点的坐标,按逆时针顺序给出。题目保证所给多边形满足题面中描述的条件。
矩形窗口的所有坐标以及多边形所有顶点的坐标均为非负整数,且均不超过 15000。
输出格式
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.
该示例对应于上方的图片。
输入解题思路,AI测评打分。不知道怎么写?