You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.6 KiB

2 years ago
#include <bits/stdc++.h>
/*油漆面积
X
便怀
(x1,y1,x2,y2)
n(1<=n<10000)
n4x1 y1 x2 y2
(0<= x1,y1,x2,y2 <=10000)
2
2 2 9 5
6 1 12 9
60
3
1 5 10 10
3 1 20 20
2 7 15 17
340
3
5 2 10 6
2 7 12 10
8 1 15 15
128
I
https://www.bilibili.com/video/BV1VV411z7S2?p=11
II
https://www.bilibili.com/video/BV1VV411z7S2?p=12
线+线 (线+线西~)
*/
using namespace std;
const int N = 1e4 + 10; //矩形的数量
int n, sum;
// 65536kb /1024 =64mb
// int p[N][N]; //10000*10000*4 byte =4 0000 0000 byte /1024/1024=381MB
// 0 1
bool p[N][N]; //这里需要估算一下空间因为int是8个bit,bool是1个bit。
//模拟,对于(x1,y1)->(x2,y2)内的所有单元格,都标识为已被刷过油漆
//注意一下这里坐标与单元格的映射关系,就把每个单元格的左下角坐标认为是单元格的编号
void paint(int x1, int y1, int x2, int y2) {
for (int i = x1; i < x2; i++)
for (int j = y1; j < y2; j++)
p[i][j] = 1;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
paint(x1, y1, x2, y2);
}
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
if (p[i][j]) sum++;
cout << sum << endl;
return 0;
}