-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1018.cpp
More file actions
73 lines (68 loc) · 1.8 KB
/
1018.cpp
File metadata and controls
73 lines (68 loc) · 1.8 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
#include <iostream>
#include <vector>
using namespace std;
char arr[51][51];
int mn=2501;
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m,cnt,a,b;
char pre;
cin>>n>>m;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
cin>>arr[i][j];
}
}
for (int k = 0; k <= n-8; ++k)
{
for (int l = 0; l <= m-8 ; ++l)
{
for (int p = 0; p < 2; ++p)
{
for (int i = k; i < k+8; ++i)
{
for (int j = l; j < l+8; ++j)
{
if(i==k&&j==l)
{
if(p==0) pre = 'W';
else pre = 'B';
}
if(pre==arr[i][j]){
cnt++;
//cout<<pre<<" gpre ";
//cout<<i<<j<<"\n";
if(pre=='B')
{
if(j!=l+7)pre='W';
}
else
{
if(j!=l+7)pre='B';
}
}
else
{
if(j!=l+7) pre = arr[i][j];
//cout<<pre<<" rpre \n";
}
}
}
//cout<<cnt<<" cntcnt\n";
if(cnt<mn){
mn = cnt;
a = k;
b = l;
}
cnt = 0;
}
}
}
cout<<mn<<"\n";
return 0;
}