Current work
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int M;
|
||||
cin >> M;
|
||||
for (int u = 0; u < M; u++) {
|
||||
int n, a, b;
|
||||
cin >> n >> a >> b;
|
||||
vector<vector<char>> grid(n, vector<char>(n));
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
cin >> grid[i][j];
|
||||
}
|
||||
}
|
||||
int res = 0;
|
||||
|
||||
for (int i = b; i < n; i++) {
|
||||
for (int j = a; j < n; j++) {
|
||||
char c = grid[i][j], pc = grid[i + b][j + a];
|
||||
if (c == 'B') {
|
||||
if (pc == 'W') {
|
||||
res = -1;
|
||||
goto fin;
|
||||
} else {
|
||||
res += 2;
|
||||
}
|
||||
} else if (c == 'W') {
|
||||
continue;
|
||||
} else {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fin:
|
||||
cout << res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user