A12953 | Guarding warehouses
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Bob Bubblestrong just got a new job as security guard. Bob is now responsible for safety of a collection of warehouses, each containing the most valuable Bubble Cup assets - the high-quality bubbles. His task is to detect thieves inside the warehouses and call the police.
Looking from the sky, each warehouse has a shape of a convex polygon. Walls of no two warehouses intersect, and of course, none of the warehouses is built inside of another warehouse.
Little did the Bubble Cup bosses know how lazy Bob is and that he enjoys watching soap operas (he heard they are full of bubbles) from the coziness of his office. Instead of going from one warehouse to another to check if warehouses are secured, the plan Bob has is to monitor all the warehouses from the comfort of his office using the special X-ray goggles. The goggles have an infinite range, so a thief in any of the warehouses could easily be spotted.
However, the goggles promptly broke and the X-rays are now strong only enough to let Bob see through a single wall. Now, Bob would really appreciate if you could help him find out what is the total area inside of the warehouses monitored by the broken goggles, so that he could know how much area of the warehouses he needs to monitor in person.
Looking from the sky, each warehouse has a shape of a convex polygon. Walls of no two warehouses intersect, and of course, none of the warehouses is built inside of another warehouse.
Little did the Bubble Cup bosses know how lazy Bob is and that he enjoys watching soap operas (he heard they are full of bubbles) from the coziness of his office. Instead of going from one warehouse to another to check if warehouses are secured, the plan Bob has is to monitor all the warehouses from the comfort of his office using the special X-ray goggles. The goggles have an infinite range, so a thief in any of the warehouses could easily be spotted.
However, the goggles promptly broke and the X-rays are now strong only enough to let Bob see through a single wall. Now, Bob would really appreciate if you could help him find out what is the total area inside of the warehouses monitored by the broken goggles, so that he could know how much area of the warehouses he needs to monitor in person.
输入格式
The first line contains one integer $N$ ( $1$ $\leq$ $N$ $\leq$ $10^4$ ) – the number of warehouses.
The next $N$ lines describe the warehouses.
The first number of the line is integer $c_i$ ( $3$ $\leq$ $c_i$ $\leq$ $10^4$ ) – the number corners in the $i^{th}$ warehouse, followed by $c_i$ pairs of integers. The $j^{th}$ pair is $(x_j, y_j)$ – the coordinates of the $j^{th}$ corner ( $|x_j|$ , $|y_j|$ $\leq$ $3 * 10^4$ ). The corners are listed in the clockwise order. The total number of corners in all the warehouses is at most $5 * 10^4$ .
Bob's office is positioned at the point with coordinates $(0, 0)$ . The office is not contained within any of the warehouses.
The next $N$ lines describe the warehouses.
The first number of the line is integer $c_i$ ( $3$ $\leq$ $c_i$ $\leq$ $10^4$ ) – the number corners in the $i^{th}$ warehouse, followed by $c_i$ pairs of integers. The $j^{th}$ pair is $(x_j, y_j)$ – the coordinates of the $j^{th}$ corner ( $|x_j|$ , $|y_j|$ $\leq$ $3 * 10^4$ ). The corners are listed in the clockwise order. The total number of corners in all the warehouses is at most $5 * 10^4$ .
Bob's office is positioned at the point with coordinates $(0, 0)$ . The office is not contained within any of the warehouses.
输出格式
Print a single line containing a single decimal number accurate to at least four decimal places – the total area of the warehouses Bob can monitor using the broken X-ray goggles.
输入输出样例
输入 #1
5 4 1 1 1 3 3 3 3 1 4 4 3 6 2 6 0 4 0 6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2 3 0 -1 1 -3 -1 -3 4 1 -4 1 -6 -1 -6 -1 -4
输出 #1
13.333333333333
Areas monitored by the X-ray goggles are colored green and areas not monitored by the goggles are colored red.
The warehouses $ABCD$ , $IJK$ and $LMNOPQ$ are completely monitored using the googles.
The warehouse $EFGH$ is partially monitored using the goggles: part $EFW$ is not monitored because to monitor each point inside it, the X-rays must go through two walls of warehouse $ABCD$ .
The warehouse $RUTS$ is not monitored from the Bob's office, because there are two walls of the warehouse $IJK$ between Bob's office and each point in $RUTS$ .
The total area monitored by the goggles is $P$ = $P_{ABCD}$ + $P_{FGHW}$ + $P_{IJK}$ + $P_{LMNOPQ}$ = $4$ + $3.333333333333$ + $2$ + $4$ = $13.333333333333$ .
The warehouses $ABCD$ , $IJK$ and $LMNOPQ$ are completely monitored using the googles.
The warehouse $EFGH$ is partially monitored using the goggles: part $EFW$ is not monitored because to monitor each point inside it, the X-rays must go through two walls of warehouse $ABCD$ .
The warehouse $RUTS$ is not monitored from the Bob's office, because there are two walls of the warehouse $IJK$ between Bob's office and each point in $RUTS$ .
The total area monitored by the goggles is $P$ = $P_{ABCD}$ + $P_{FGHW}$ + $P_{IJK}$ + $P_{LMNOPQ}$ = $4$ + $3.333333333333$ + $2$ + $4$ = $13.333333333333$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted