Language: C++

#include <bits/stdc++.h>
using namespace std;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

struct lattice{
  bool wallB,wallW,black,white;
};

struct zahyou{
  int x;
  int y;
};

int main() {
  vector<int> ans_B,ans_W;
  while(1){
    int w,h;
    char a;
    cin >> w >> h;
    if(!w && !h)break;
    vector<vector<lattice> > v(h+2);
    for(int i = 1;i <= h;i++){
      vector<lattice> q(w+2);
      lattice l;
      l.wallB = 0;
      l.wallW = 0;
      l.black = 0;
      l.white = 0;
      q[0] = l;
      q[h+1] = l;
      for(int j = 1;j <= w;j++){
        cin >> a;
        l.wallB = 0;
        l.wallW = 0;
        l.black = 0;
        l.white = 0;
        if(a == 'W')l.wallW = 1;
        if(a == 'B')l.wallB = 1;
        q[j] = l;
      }
      v[i] = q;
    }



    for(int j = 0;j <= w+1;j++){
      lattice l;
      l.wallB = 0;
      l.wallW = 0;
      l.black = 0;
      l.white = 0;
      v[0].push_back(l);
      v[h+1].push_back(l);
    }
    
    for(int i = 1;i <= h;i++){
      for(int j = 1;j <= w;j++){
        if(v[i][j].wallW){
          queue<zahyou> que;
          zahyou z;
          z.x = i;
          z.y = j;
          que.push(z);
          while(que.size()){
            cout << que.size() << endl;
            for(int k = 0;k < 4;k++){
              if(1 <= que.front().x && que.front().x <= h && 1 <= que.front().y && que.front().y <= w){
                if(!v[que.front().x + dx[k]][que.front().y + dy[k]].white && !v[que.front().x + dx[k]][que.front().y + dy[k]].wallB && !v[que.front().x + dx[k]][que.front().y + dy[k]].wallW){
                  z.x = que.front().x + dx[k];
                  z.y = que.front().y + dy[k];
                  que.push(z);
                  v[que.front().x + dx[k]][que.front().y + dy[k]].white = 1;
                }
              }
            }
            que.pop();
          }
        }
        if(v[i][j].wallB){
          queue<zahyou> que;
          zahyou z;
          z.x = i;
          z.y = j;
          que.push(z);
          while(que.size()){
            cout << que.size() << endl;
            for(int k = 0;k < 4;k++){
              if(1 <= que.front().x && que.front().x <= h && 1 <= que.front().y && que.front().y <= w){
                if(!v[que.front().x + dx[k]][que.front().y + dy[k]].black && !v[que.front().x + dx[k]][que.front().y + dy[k]].wallB && !v[que.front().x + dx[k]][que.front().y + dy[k]].wallW){
                  z.x = que.front().x + dx[k];
                  z.y = que.front().y + dy[k];
                  que.push(z);
                  v[que.front().x + dx[k]][que.front().y + dy[k]].black = 1;
                }
              }
            }
            que.pop();
          }
        }
      }
    }
    int countB=0,countW=0;
    for(int i = 1;i <= h;i++){
      for(int j = 1;j <= w;j++){
        if(v[i][j].black && v[i][j].white){}
        else if(v[i][j].black && !v[i][j].wallB && !v[i][j].wallW){
          countB++;
        }
        else if(v[i][j].white && !v[i][j].wallB && !v[i][j].wallW){
          countW++;
        }
      }
    }
    ans_B.push_back(countB);
    ans_W.push_back(countW);
  }
  for(int i = 0;i < ans_B.size();i++)cout << ans_B[i] << " " << ans_W[i] << endl;
}

44 15
BB.BBWWB.W.W.B.WWBWBBWWWB.BWWBBBWWBBWBWB.W.W
WBW..B..BWWBWBBWWBWB..BWBWB...B.WBWBW...W.W.
...WBWWBBW.BBB.WB.B.WW.B.WBBBB.BWBBBW.W.B.BB
W.B.B.W.WWBBWBB..B...WWWWB.WBWWWBWBB.W.BBBW.
.WW.WB.WWB.WBW...BB...BBWWBWW..BWW.WWBB.B.B.
.WW..WBW.BWWWB..WBB..W.WBWWBBWW.BBWWWWW....W
..W.WWBBB..BBBB..BW.BBBBBWWBBBWWW..WW..B.BBW
BBW.BWBBBWWBB..BWW.W..BWWW.WB.BBWWBW..WB.WWB
B.BB....W.BW.BWW..WBBBW.....WB.W.WBWBB.WBB.B
B.WWW...W..WWBBW.BBWWBB....WWBWWWBW..WW.BWBB
W.WWWWWBWBWWWBB..W.BBBBB...B.BWWWW.WW..WB.WB



Compiler output:
a.cc:122:1: error: expected unqualified-id before numeric constant
  122 | 44 15
      | ^~