【每日一题40】3203. 画图

Day40 AcWing 3203. 画图

思路

  1. 暴力模拟
  2. bool数组

拓展

  1. 扫描线 247. 亚特兰蒂斯

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 110;

int n;
bool st[N][N];

int main()
{
cin >> n;
while (n -- )
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
for (int i = x1; i < x2; i ++ )
for (int j = y1; j < y2; j ++ )
st[i][j] = true;
}

int res = 0;
for (int i = 0; i < N; i ++ )
for (int j = 0; j < N; j ++ )
res += st[i][j];
cout << res << endl;

return 0;
}