이전에 비슷한 문제를 푼 적 있어서 쉽게 풀 수 있었다
영역이 100 * 100 밖에 안 되니깐 그냥 색종이를 덮은 영역을 전부 1로 만들어주고
마지막에 1의 개수만 구하는 방식으로 구현했다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
using namespace std;
int v[105][105];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
for (int i = x; i < x + 10; i++)
{
for (int j = y; j < y + 10; j++)
v[i][j] = 1;
}
}
int cnt = 0;
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 100; j++)
{
if (v[i][j] == 1)
cnt++;
}
}
cout << cnt << endl;
return 0;
}
'백준' 카테고리의 다른 글
10826 피보나치 수 4 (2) | 2020.09.29 |
---|---|
2670 연속부분최대곱 (0) | 2020.09.28 |
18221 교수님 저는 취업할래요 (0) | 2020.09.28 |
5622 다이얼 (0) | 2020.09.28 |
1166 선물 (0) | 2020.09.26 |