-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1018.cpp
More file actions
76 lines (74 loc) · 1.48 KB
/
boj1018.cpp
File metadata and controls
76 lines (74 loc) · 1.48 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
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
string WB[8] = {
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW"
};
string BW[8] = {
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB"
};
string board[50];
int WB_cnt(int x, int y)
{
int cnt = 0;
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
if (board[x + i][y + j] != WB[i][j])
cnt++;
}
}
return cnt;
}
int BW_cnt(int x, int y)
{
int cnt = 0;
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
if (board[x + i][y + j] != BW[i][j])
cnt++;
}
}
return cnt;
}
int main() {
int size[2];
int cnt;
int min_val = 12345;
pair<int, int> p1;
cin >> p1.first >> p1.second;
for (int i = 0; i < p1.first; i++)
cin >> board[i];
for (int i = 0; i + 8 <= p1.first; i++)
{
for (int j = 0; j + 8 <= p1.second; j++)
{
int tmp;
tmp = min(WB_cnt(i, j), BW_cnt(i, j));
if (tmp < min_val) {
min_val = tmp;
}
}
}
cout << min_val;
return 0;
}