-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1018.cpp
More file actions
99 lines (83 loc) · 1.77 KB
/
1018.cpp
File metadata and controls
99 lines (83 loc) · 1.77 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
using namespace std;
int main()
{
int N = 0, M = 0;
int colorCount = 0;
int wCount = 0;
int bCount = 0;
bool _ColorStack = true;
cin >> N >> M;
int min_colorCount = N * M;
char** Chess = new char* [N];
for (int i = 0; i < N; i++)
Chess[i] = new char[M];
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
cin >> Chess[i][j];
}
for (int x = 0; x <= N - 8; x++)
{
for (int y = 0; y <= M - 8; y++)
{
wCount = 0;
bCount = 0;
// 만약 시작이 W 라면
{
_ColorStack = true;
for (int i = x; i < x + 8; i++)
{
for (int j = y; j < y + 8; j++)
{
if (_ColorStack) // W가 칠해져야 할 차례
{
if (Chess[i][j] != 'W')
colorCount++;
}
else // B가 칠해져야 할 차례
{
if (Chess[i][j] == 'W')
colorCount++;
}
_ColorStack = !_ColorStack;
}
_ColorStack = !_ColorStack;
}
wCount = colorCount;
colorCount = 0;
}
{
_ColorStack = false;
for (int i = x; i < x + 8; i++)
{
for (int j = y; j < y + 8; j++)
{
if (!_ColorStack) // B가 칠해져야 할 차례
{
if (Chess[i][j] != 'B')
colorCount++;
}
else // W가 칠해져야 할 차례
{
if (Chess[i][j] == 'B')
colorCount++;
}
_ColorStack = !_ColorStack;
}
_ColorStack = !_ColorStack;
}
bCount = colorCount;
colorCount = 0;
}
if (wCount >= bCount)
colorCount = bCount;
else
colorCount = wCount;
if (min_colorCount > colorCount)
min_colorCount = colorCount;
colorCount = 0;
}
}
cout << min_colorCount;
}