We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aeba177 commit 47b72c7Copy full SHA for 47b72c7
1018
49 KB
1018.cpp
@@ -0,0 +1,27 @@
1
+#include <iostream>
2
+
3
+int main(){
4
+ int n, m;
5
+ char b[51][51];
6
+ scanf("%d%d", &n, &m);
7
+ for(int i=0;i<n;i++){
8
+ scanf("%s", b[i]);
9
+ }
10
11
+ int min=10000000;
12
+ for(int sx=0;sx<=n-8;sx++){
13
+ for(int sy=0;sy<=m-8;sy++){
14
+ int wrong=0;
15
+ for(int i=sx;i<sx+8;i++){
16
+ for(int j=sy;j<sy+8;j++){
17
+ if((i+j)%2==0 && b[i][j]=='B') wrong++;
18
+ else if((i+j)%2==1 && b[i][j]=='W') wrong++;
19
20
21
+ wrong=(wrong<64-wrong)?wrong:64-wrong;
22
+ if(wrong<min) min=wrong;
23
24
25
+ printf("%d\n", min);
26
27
+}
1389_2
0 Bytes
0 commit comments