-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1018.cpp
39 lines (32 loc) · 863 Bytes
/
1018.cpp
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
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<string> board;
for (int i = 0; i < N; ++i) {
string row;
cin >> row;
board.push_back(row);
}
char color[2] = {'W', 'B'};
int minimumFix = 8 * 8;
for (int i = 0; i < N - 8 + 1; ++i) {
for (int j = 0; j < M - 8 + 1; ++j) {
for (int c = 0; c < 2; ++c) {
int fix = 0;
for (int n = 0; n < 8; ++n) {
for (int m = 0; m < 8; ++m) {
if (board[n + i][m + j] != color[(n + m + c) % 2])
++fix;
}
}
if (minimumFix > fix)
minimumFix = fix;
}
}
}
cout << minimumFix;
}