와ㅋㅋ 이거 2년전에 포기했던 문제인데
저렇게 사각형 두는 문제들 전부 색칠하면 편하게 풀 수 있다. 105 * 105 사이즈 도화지를 두고 직접 색종이를 색칠한다.
둘레를 구하는 방법은 흰 부분 기준으로 상하좌우에 검은 칸 있으면 ++ 하는 걸로 해결할 수 있음
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#include <stdio.h>
#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 iis = pair<int, string>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
bool mapv[105][105];
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int main() {
int n;
scanf("%d", &n);
for (int k = 0; k < n; k++) {
int x, y;
scanf("%d %d", &x, &y);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
mapv[x + i][y + j] = true;
}
}
}
int ans = 0;
for (int i = 0; i <= 101; i++) {
for (int j = 0; j <= 101; j++) {
for (int k = 0; k < 4; k++) {
if (mapv[i][j])
continue;
int nx = dx[k] + i;
int ny = dy[k] + j;
if (nx < 0 || 101 < nx || ny < 0 || 101 < ny)
continue;
if (mapv[nx][ny])
ans++;
}
}
}
cout << ans << endl;
return 0;
}
'백준' 카테고리의 다른 글
12933 오리 (0) | 2021.08.03 |
---|---|
1018 체스판 다시 칠하기 (0) | 2021.08.01 |
2018 수들의 합 5 (0) | 2021.08.01 |
22352 항체 인식 (0) | 2021.08.01 |
1916 최소비용 구하기 (0) | 2021.07.31 |