Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- baekjoon
- C++
- Programmers
- RootMotion
- 팰린드롬 만들기
- winapi
- DirectX11
- GeeksForGeeks
- UnrealEngine5
- 프로그래머스
- 줄 세우기
- 오블완
- 백준
- DeferredRendering
- 티스토리챌린지
- 언리얼엔진5
- directx
- Unreal Engine5
- 2294
- algorithm
- IFileDialog
- softeer
- UnrealEngine4
- RVO
- 1563
- NRVO
- const
- UE5
- C
- Frustum
Archives
- Today
- Total
Game Develop
[Algorithm] Baekjoon 1926번 : 그림 본문
https://www.acmicpc.net/problem/1926
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
struct Node
{
int y;
int x;
};
int row, col;
int arr[501][501];
int dir[4][2] = { {-1,0}, {1,0}, {0,-1}, {0,1} };
int getArea(int startY, int startX)
{
queue<Node> q;
q.push({ startY,startX });
arr[startY][startX] = 0;
int count = 1;
while (!q.empty())
{
int curY = q.front().y;
int curX = q.front().x;
q.pop();
for (int i = 0; i < 4; ++i)
{
int nextY = curY + dir[i][0];
int nextX = curX + dir[i][1];
if (nextY < 0 || nextY >= row) continue;
if (nextX < 0 || nextX >= col) continue;
if (!arr[nextY][nextX]) continue;
++count;
arr[nextY][nextX] = 0;
q.push({ nextY,nextX });
}
}
return count;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int maxArea = 0;
int count = 0;
cin >> row >> col;
for (int i = 0; i < row; ++i)
{
for (int j = 0; j < col; ++j)
{
cin >> arr[i][j];
}
}
for (int i = 0; i < row; ++i)
{
for (int j = 0; j < col; ++j)
{
if (arr[i][j] == 0) continue;
++count;
maxArea = max(maxArea, getArea(i, j));
}
}
cout << count << endl << maxArea;
}
|
cs |
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm] Baekjoon 5427번 : 불 (0) | 2023.02.25 |
---|---|
[Algorithm] Baekjoon 4179번 : 불! (0) | 2023.02.25 |
[Algorithm] Baekjoon 14503번 : 로봇 청소기 (0) | 2023.02.13 |
[Algorithm] Baekjoon 9205번 : 맥주 마시면서 걸어가기 (0) | 2023.02.13 |
[Algorithm] Baekjoon 2573번 : 빙산 (0) | 2023.02.13 |