Overlapping Rectangles
来源:互联网 发布:优化软件点击 编辑:程序博客网 时间:2024/06/04 19:05
There are nnn rectangles on the plane. The problem is to find the area of the union of these rectangles. Note that these rectangles might overlap with each other, and the overlapped areas of these rectangles shall not be counted more than once. For example, given a rectangleAAA with the bottom left corner located at (0,0)(0, 0)(0,0) and the top right corner at (2,2)(2, 2)(2,2), and the other rectangle BBB with the bottom left corner located at (1,1)(1,1)(1,1) and the top right corner at (3,3)(3,3)(3,3), it follows that the area of the union of AAA and BBB should be 777, instead of 888.
Although the problem looks simple at the first glance, it might take a while to figure out how to do it correctly. Note that the shape of the union can be very complicated, and the intersected areas can be overlapped by more than two rectangles.
Note:
(1) The coordinates of these rectangles are given in integers. So you do not have to worry about the floating point round-off errors. However, these integers can be as large as1,000,0001,000,0001,000,000.
(2) To make the problem easier, you do not have to worry about the sum of the areas exceeding the long integer precision. That is, you can assume that the total area does not result in integer overflow.
Input Format
Several sets of rectangles configurations. The inputs are a list of integers. Within each set, the first integer (in a single line) represents the number of rectangles, n, which can be as large as100010001000. After n, there will be n lines representing the n rectangles; each line contains four integers<a,b,c,d><a, b, c, d><a,b,c,d> , which means that the bottom left corner of the rectangle is located at (a,b)(a, b)(a,b), and the top right corner of the rectangle is located at (c,d)(c, d)(c,d). Note that integers aaa,bbb,ccc,ddd can be as large as 1,000,0001,000,0001,000,000.
These configurations of rectangles occur repetitively in the input as the pattern described above. An integern=0n = 0n=0 (zero) signifies the end of input.
Output Format
For each set of the rectangles configurations appeared in the input, calculate the total area of the union of the rectangles. Again, these rectangles might overlap each other, and the intersecting areas of these rectangles can only be counted once. Output a single star '*' to signify the end of outputs.
样例输入
20 0 2 21 1 3 330 0 1 12 2 3 34 4 5 50
样例输出
73*
待解决
- Overlapping Rectangles
- Overlapping Rectangles
- ???Overlapping Rectangles
- OVERLAPPING RECTANGLES题解
- UVa 460 - Overlapping Rectangles
- 计蒜客 17313 Overlapping Rectangles
- Overlapping Rectangles(线段树,矩形面积并)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 F. Overlapping Rectangles(扫描线)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 F. Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 F. Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: F. Overlapping Rectangles(线段树)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:Overlapping Rectangles
- 矩形面积并集,2017ICPC网络赛(南宁)Overlapping Rectangles
- 2017 icpc 南宁赛区 F.Overlapping Rectangles(重叠矩形的最大面积+线段树模板)
- 2017南宁网络赛F.Overlapping Rectangles(扫描线法+线段树)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 F. Overlapping Rectangles(面积并)
- 启动tomcat失败,原因端口占用,但是不能通过结束服务关掉tomcat解决方法
- [施工...][业界良心]数论
- poj3734(矩阵快速幂)
- Java实现快速排序
- 查找
- Overlapping Rectangles
- 向上取整和向下取整
- How to install mysql 5.5 or 5.6 on ubuntu 16.04 xenial
- 学习笔记之面向对象编程23(多线程机制2)
- 接口自动化测试-xlrd模块处理表格文件
- Map Reduce操作步骤
- 通过分频器和乘法器来实现对频率的减倍和倍增效果
- STM32低功耗实验总结
- 2. Add Two Numbers