#include #include using namespace std ; int off, h, w, r=0 ; vector b ; int f(int i, int j) { return off * (i + 1) + (j + 1) ; } void chase(int at) { if (b[at] == 'W' || b[at] == 0) return ; b[at] = 0 ; for (int i : vector{-1, 1, -off, off}) chase(at+i) ; } int main() { cin >> h >> w ; b = vector((h+2)*(w+2)) ; off = w + 1 ; for (int i=0; i> b[f(i,j)] ; for (int i=0; i