hdu 1866 几个矩形面积的和 ***

给出几个矩形,求出面积之和,相交区域只能算一次

一开始想用线段树求个并,后来发现没办法知道并了几次,然后就不会了

看了题解

本题其实很简单,但是想要想到转化也很不容易,因为本题是求面积之和,但是两个矩形有可能会重合在一起,所以这是就需要将所有矩形的分割成一个一个单位的小正方形。这样就可以对他们进行标记。最后查找被标记小正方形的个数。

看了下数据范围,果然可以23333,做题越多越觉得智商不够

题解链接

时间: 2024-10-04 10:23:18

hdu 1866 几个矩形面积的和 ***的相关文章

HDU 1542 —— Atlantis 【矩形面积并:扫描线】

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=14795 #include <iostream> #include <cstring> #include <string> #include <algorithm> #define left rt<<1 #define right rt<<1|1 using namespace std; const int MAX

HDU 1542 Atlantis (求矩形面积并)

Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of

【HDU 1542】Atlantis 矩形面积并(线段树,扫描法)

[题目] Atlantis Problem Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe different regions of

HDU 3265 扫描线(矩形面积并变形)

Posters Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5230    Accepted Submission(s): 1220 Problem Description Ted has a new house with a huge window. In this big summer, Ted decides to decora

HDU 1542 Atlantis(矩形面积并)

HDU 1542 Atlantis 题目链接 题意:给定一些矩形,求面积并 思路:利用扫描线,因为这题矩形个数不多,直接暴力扫就能够了.假设数据大.就要用线段树 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int N = 205; const int M = 100005; const dou

[HDU 4419] Colourful Rectangle (扫描线 矩形面积并)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4419 题目大意:比矩形面积并多了颜色,问染成的每种颜色的面积. 矩形面积并的扫描线维护的是长度,这道题就是维护每个颜色的长度,写起来很蛋疼. 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 #include <cstring> 5 #include <vector> 6

HDU 1264 Counting Squares (线段树-扫描线-矩形面积并)

Problem A : Counting Squares From:HDU, 1264 Problem Description Your input is a series of rectangles, one per line. Each rectangle is specified as two points(X,Y) that specify the opposite corners of a rectangle. All coordinates will be integers in t

HDU 1255 覆盖的面积 (求矩形面积的交)

覆盖的面积 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input 输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测试数据的第一行是一个正整数N(1<=N<=1000),代表矩形的数量,然后是N行数据,每一行包含四个浮点数,代表平面上的一个

hdu 1505 City Game 最大矩形面积 单调队列

City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5106    Accepted Submission(s): 2197 Problem Description Bob is a strategy game programming specialist. In his new city building game t