QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736028#5071. Check Pattern is GoodlalaouyeTL 7220ms6984kbC++144.0kb2024-11-11 23:40:322024-11-11 23:40:32

Judging History

你现在查看的是最新测评结果

  • [2024-11-11 23:40:32]
  • 评测
  • 测评结果:TL
  • 用时:7220ms
  • 内存:6984kb
  • [2024-11-11 23:40:32]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i (l); i <= r; ++ i)
#define rrp(i, l, r) for (int i (r); i >= l; -- i)
#define pii pair <int, int>
#define eb emplace_back
#define ls p << 1
#define rs ls | 1
#define inf 1000000000
using namespace std;
constexpr int N = 100 + 5;
typedef unsigned long long ull;
typedef long long ll;
inline ll rd () {
  ll x = 0, f = 1;
  char ch = getchar ();
  while (! isdigit (ch)) {
    if (ch == '-') f = -1;
    ch = getchar ();
  }
  while (isdigit (ch)) {
    x = (x << 1) + (x << 3) + ch - 48;
    ch = getchar ();
  }
  return x * f;
}
int n, m;
char s[N][N];
int id[N][N][2];
vector <int> e[N * N << 1];
int col[N * N << 1], match[N * N << 1];
int vis[N * N << 1];
int stk[N * N << 1], top;
int chg[N * N << 1];
bool dfs (int u) {
  for (auto v : e[u]) {
    if (vis[v]) continue;
    vis[v] = 1; stk[++ top] = v;
    if (! match[v] || dfs (match[v])) return match[v] = u, 1;
  } return 0;
}
void dfs (int u, int now) {
  if (col[u] != -1) return ;
  col[u] = now;
  for (auto v : e[u]) dfs (v, ! now);
}
void solve () {
  n = rd (), m = rd ();
  rep (i, 1, n) scanf ("%s", s[i] + 1);
  rep (i, 1, n) rep (j, 1, m) rep (k, 0, 1) id[i][j][k] = 0;
  int tot = 0, ans = 0;
  rep (i, 1, n - 1) {
    rep (j, 1, m - 1) {
      if (s[i][j] == '?' || s[i][j + 1] == '?' || s[i + 1][j] == '?' || s[i + 1][j + 1] == '?') {
        if (s[i][j] != 'W' && s[i + 1][j] != 'B' && s[i][j + 1] != 'B' && s[i + 1][j + 1] != 'W') id[i][j][0] = ++ tot;
        if (s[i][j] != 'B' && s[i + 1][j] != 'W' && s[i][j + 1] != 'W' && s[i + 1][j + 1] != 'B') id[i][j][1] = ++ tot;
      } else {
        ans += s[i][j] == s[i + 1][j + 1] && s[i][j] != s[i + 1][j] && s[i][j] != s[i][j + 1];
      }
    }
  }
  rep (i, 1, n - 1) {
    rep (j, 1, m - 1) {
      rep (k, 0, 1) {
        if (! id[i][j][k]) continue;
        if (id[i][j][! k]) e[id[i][j][k]].eb (id[i][j][! k]);
        if (id[i][j + 1][k]) e[id[i][j][k]].eb (id[i][j + 1][k]), e[id[i][j + 1][k]].eb (id[i][j][k]);//,cout<<id[i][j][k]<<" "<<id[i][j+1][k]<<endl;
        if (id[i + 1][j][k]) e[id[i][j][k]].eb (id[i + 1][j][k]), e[id[i + 1][j][k]].eb (id[i][j][k]);//,cout<<id[i][j][k]<<" "<<id[i+1][j][k]<<endl;
        if (id[i + 1][j + 1][! k]) e[id[i][j][k]].eb (id[i + 1][j + 1][! k]), e[id[i + 1][j + 1][! k]].eb (id[i][j][k]);//,cout<<id[i][j][k]<<" "<<id[i+1][j+1][!k]<<endl;
        if (id[i + 1][j - 1][! k]) e[id[i][j][k]].eb (id[i + 1][j - 1][! k]), e[id[i + 1][j - 1][! k]].eb (id[i][j][k]);
      
      }
    }
  }
  fill (col + 1, col + tot + 1, -1);
  mt19937 rnd (time (0));
  rep (i, 1, tot) shuffle (e[i].begin (), e[i].end (), rnd);
  rep (i, 1, tot) {
    if (col[i] == -1) dfs (i, 0);
  }
  rep (i, 1, tot) {
    if (! col[i]) ans -= dfs (i);
    while (top) vis[stk[top --]] = 0;
  }
  rep (i, 1, tot) if (col[i] && match[i]) match[match[i]] = i;
  queue <int> q;
  rep (i, 1, tot) vis[i] = -1; 
  rep (i, 1, tot) {
    if (! match[i]) {
      vis[i] = 1; 
      for (auto v : e[i]) if (vis[v] == -1) vis[v] = 0, q.push (v);
    }
  } 
  while (! q.empty ()) {
    int u = q.front ();
    q.pop ();
    int v = match[u];
    if (vis[v] == -1) {
      vis[v] = 1;
      for (auto w : e[v]) {
        if (vis[w] == -1) vis[w] = 0, q.push (w);
      }
    }
  }
  rep (i, 1, tot) if (vis[i] == -1 && vis[match[i]] == -1 && col[i] == 0) vis[i] = 1;
  rep (i, 1, n - 1) {
    rep (j, 1, m - 1) {
      if (vis[id[i][j][0]] == 1) s[i][j] = 'B', s[i + 1][j] = 'W', s[i][j + 1] = 'W', s[i + 1][j + 1] = 'B';
      if (vis[id[i][j][1]] == 1) s[i][j] = 'W', s[i + 1][j] = 'B', s[i][j + 1] = 'B', s[i + 1][j + 1] = 'W';
    }
  }
  printf ("%d\n", ans + tot);
  rep (i, 1, n) {
    rep (j, 1, m) if (s[i][j] != '?') putchar (s[i][j]); else putchar ('B');
    puts ("");
  } 
  rep (i, 1, tot) e[i].clear (), match[i] = 0, vis[i] = 0;
}
int main () {
  // freopen ("1.in", "r", stdin);
  // freopen ("1.out", "w", stdout);
  for (int T (rd ()); T; -- T) solve ();  
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4356kb

input:

3
2 2
??
??
3 3
BW?
W?B
?BW
3 3
BW?
W?W
?W?

output:

1
BW
WB
1
BWB
WBB
BBW
4
BWB
WBW
BWB

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 33ms
memory: 4432kb

input:

10000
9 2
BB
BW
WW
WW
?W
?B
B?
W?
BB
6 2
??
?B
B?
BW
WW
??
10 7
WBBBW??
???BWWW
???BWWB
??WWBW?
BBWBBWB
WWB?WW?
BWBW???
WWWWBBW
BBWBB?W
B?W?W?B
4 7
??WBWWB
?BBWWWB
?W?BBB?
BBBWBBB
10 1
B
W
?
B
B
W
W
W
B
?
10 4
??WW
W?W?
WWW?
???W
?W??
?W?W
W?W?
?W?W
???W
???W
8 3
WBW
W??
???
???
W?W
W?W
???
?W?
4 1
...

output:

3
BB
BW
WW
WW
BW
WB
BW
WB
BB
2
BW
WB
BW
BW
WW
BB
9
WBBBWBB
BWBBWWW
WBWBWWB
BWWWBWB
BBWBBWB
WWBWWWB
BWBWBBW
WWWWBBW
BBWBBWW
BBWBWBB
6
BWWBWWB
WBBWWWB
BWWBBBW
BBBWBBB
0
B
W
B
B
B
W
W
W
B
B
15
BWWW
WBWB
WWWB
WBBW
BWWB
BWBW
WBWB
BWBW
WBWW
BWBW
8
WBW
WWB
WBW
BWB
WBW
WBW
BWB
BWB
0
W
B
B
B
1
BBWB
WWBB
3
BW...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 32ms
memory: 4456kb

input:

10000
9 6
?B?W?W
WWBBWB
?WB?BW
B?W?W?
WW??W?
B???BW
?W?WW?
W?B?B?
?W?BB?
10 1
W
?
?
?
?
?
?
?
B
W
9 4
????
????
W???
?W?B
??WW
?BW?
WW?W
??W?
??W?
3 2
?W
?B
BB
2 7
?W?BWWB
??W???W
9 9
?BW?WWW?W
BW?WBBWWW
W?W????WW
W??WW??WW
W?BWB?B?W
??BB?WWWW
W???WBW?W
WWW???WWW
B?WWWWWW?
8 10
W??BWWW??B
?BWBWBW?BW...

output:

21
BBWWBW
WWBBWB
BWBWBW
BBWBWB
WWBWWB
BBWBBW
BWBWWB
WBBWBW
BWWBBB
0
W
B
B
B
B
B
B
B
B
W
15
WBWB
BWBW
WBWB
BWBB
WBWW
BBWB
WWBW
WBWB
BWWB
1
BW
WB
BB
4
BWBBWWB
WBWWBBW
20
WBWBWWWBW
BWBWBBWWW
WBWBWWBWW
WWBWWBWWW
WBBWBWBBW
BWBBWWWWW
WBWBWBWBW
WWWWBWWWW
BBWWWWWWB
28
WWBBWWWBWB
WBWBWBWWBW
BWBWBWBWBW
WBWWBW...

result:

ok ok (10000 test cases)

Test #4:

score: 0
Accepted
time: 36ms
memory: 4628kb

input:

10000
7 7
?B??BBW
????BB?
WBBB??B
WW?B???
?B??BBB
BBWB??B
B???BB?
10 6
W?WW??
W??W??
?WWWW?
?WW?WW
WW??W?
W?????
W?WW??
WW???W
WWW??W
?W??W?
2 6
?B??W?
B???BB
1 8
??BWB?W?
5 2
WB
W?
B?
BB
?W
7 5
W????
?WW??
???W?
WWWW?
W?W?W
?W?B?
W?WWB
8 5
B?WBW
B??WW
WWW?B
WBBWB
BW?WW
B?W?B
??WWB
BBW?B
10 4
WWWW
?...

output:

15
WBWBBBW
BWBWBBW
WBBBWWB
WWWBWBW
BBBWBBB
BBWBWWB
BWBWBBW
13
WBWWWB
WWBWBW
BWWWWB
BWWBWW
WWBWWB
WBWBWB
WBWWBW
WWBBWW
WWWWBW
BWBBWB
4
WBWBWB
BWBWBB
0
BBBWBBWB
1
WB
WB
BW
BB
BW
12
WBBWB
BWWBW
WBBWB
WWWWB
WBWBW
BWBBW
WBWWB
7
BBWBW
BWBWW
WWWBB
WBBWB
BWBWW
BBWBB
BBWWB
BBWBB
9
WWWW
BBWB
WWBW
WBWB
BWWB
BW...

result:

ok ok (10000 test cases)

Test #5:

score: 0
Accepted
time: 36ms
memory: 4396kb

input:

10000
1 1
?
7 9
W?WB????B
?WB??B??W
BBB?W?WB?
WWW??WWW?
WW?B??W?W
?BWW??WWW
B?WW?W?WB
3 7
??BBBB?
BW?WW??
B??B?BW
1 6
?B?WWB
7 1
W
W
W
B
?
W
?
8 8
WW??W?B?
WWW?????
BB??WWWW
?W???WBW
BBW???WB
BWBWBWW?
?W?WW??B
BB?????W
10 8
WWW?W?BW
WB?W?WBW
WW?W?WBW
WWWW?WW?
WBWB?B?W
BW?BW??B
??WWBWWB
W?BW?BWW
W?W?...

output:

0
B
18
WBWBWWBWB
BWBWBBWBW
BBBBWBWBW
WWWWBWWWB
WWBBWBWBW
WBWWBWWWW
BWWWBWBWB
5
WBBBBBW
BWBWWWB
BBWBBBW
0
BBBWWB
0
W
W
W
B
B
W
B
23
WWBBWBBW
WWWWBWWB
BBWBWWWW
BWBWBWBW
BBWBWBWB
BWBWBWWB
BWBWWBWB
BBWBBWBW
19
WWWBWBBW
WBBWBWBW
WWBWBWBW
WWWWBWWB
WBWBWBBW
BWBBWBWB
WBWWBWWB
WWBWWBWW
WBWBWWWB
WWWWBBBB
0
WB...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 37ms
memory: 4376kb

input:

10000
9 1
W
B
?
B
W
W
?
W
B
1 10
W??????BWB
5 8
??W??WB?
?B?WWB?W
??????B?
BB??BBBB
WB??BBB?
6 2
?B
??
WB
?B
WW
W?
1 10
WW??BW?BW?
4 3
BW?
???
B?B
??W
10 10
WW?BBW?BW?
WW?BW?????
?WWBW?WB?W
???B?BBBBB
??BBBB?BBW
?WW??W?WBB
W??BB?WBBB
BBWBW?WBBW
?W????BWB?
??BW??WBWB
1 6
??B???
6 5
WBB?W
?WWWW
WWWW?
...

output:

0
W
B
B
B
W
W
B
W
B
0
WBBBBBBBWB
10
BWWBBWBB
WBBWWBWW
BWWBWWBB
BBBWBBBB
WBWBBBBB
2
WB
BW
WB
BB
WW
WB
0
WWBBBWBBWB
6
BWB
WBW
BWB
WBW
26
WWBBBWWBWB
WWBBWBBWBW
BWWBWBWBWW
WBWBBBBBBB
BWBBBBWBBW
BWWBBWBWBB
WBBBBBWBBB
BBWBWBWBBW
BWBWBWBWBW
WBBWWBWBWB
0
BBBBBB
4
WBBBW
BWWWW
WWWWB
WWWBW
WWBBW
WBWWB
0
B
B
B
...

result:

ok ok (10000 test cases)

Test #7:

score: 0
Accepted
time: 88ms
memory: 4444kb

input:

10000
10 10
?W?WW?W??W
?BWBW?BBWW
?BB?WWW?W?
W?B?WWWWWW
?BWW?WWW?W
BWWWWWWW?W
WBBWW??B??
W??WW?W??W
WWWW?WW?W?
?W?BWW?WW?
10 10
WB?WBBWWWB
?WWWW?WB??
?B?BWW?BW?
WBWBW??W?W
B?WB?WBWWB
WWBWBBWW??
??WBBWBWBW
WWB??WWBWB
B?BWWWWBWW
WW?WWWBWWB
10 10
??W????WW?
?WW?W???W?
??W??WW?W?
WW??WW?WW?
?W??WW?WW?
?...

output:

20
BWBWWBWWBW
WBWBWWBBWW
BBBWWWWBWB
WWBBWWWWWW
WBWWBWWWBW
BWWWWWWWBW
WBBWWWBBWB
WBBWWBWWBW
WWWWBWWBWB
BWBBWWBWWB
24
WBBWBBWWWB
BWWWWBWBBW
WBBBWWBBWB
WBWBWBWWBW
BWWBBWBWWB
WWBWBBWWBW
BBWBBWBWBW
WWBWBWWBWB
BBBWWWWBWW
WWBWWWBWWB
33
WBWWBWBWWB
BWWBWBWBWB
WBWWBWWBWB
WWBBWWBWWB
BWBBWWBWWB
BWWWBWWWBW
BWBBW...

result:

ok ok (10000 test cases)

Test #8:

score: 0
Accepted
time: 84ms
memory: 4432kb

input:

10000
10 10
?BBBBWBBB?
??W???WB??
BB?W???BB?
?B???BBB??
W??BB?WBBB
?B?B???W?W
?????BB???
?BW???B???
???BBB??BB
BWBBBBBBB?
10 10
BWW?WWB?BW
??B?WBBBWB
B??BB??BWB
BW?BWB???W
?WB?WWW?W?
B??B??W?BB
?WBB?WBB?B
BB??BBWBW?
WB??WBB?BW
?B???B?W??
10 10
??WWWB??BB
?WW???WBWW
???W??W?WW
?W?B?W?W??
WWB?WBB??W
B...

output:

34
WBBBBWBBBW
BWWBWBWBWB
BBBWBWBBBW
BBWBWBBBWB
WWBBBWWBBB
WBWBWBBWBW
BWBWBBBBWB
WBWBWWBWBW
BWBBBBWBBB
BWBBBBBBBB
31
BWWBWWBWBW
WBBWWBBBWB
BWWBBWWBWB
BWWBWBBWBW
BWBWWWWBWB
BBWBWBWWBB
BWBBBWBBWB
BBWWBBWBWB
WBWBWBBWBW
BBBWBBBWWB
33
WBWWWBBWBB
BWWBBWWBWW
WBBWWBWBWW
BWWBBWBWBB
WWBWWBBBWW
BBWBWBWWWW
BWBWB...

result:

ok ok (10000 test cases)

Test #9:

score: 0
Accepted
time: 23ms
memory: 4352kb

input:

10000
1 100
WWW?BWB?BB?BBW?BWBB?W??B?B?BWWBWB?WWB??BBBBB??BBBBB?BBBWBWWW?B?BBBWW??BBBW???B???W??W??BW?B?B?W??WB?
1 100
?WBW?WB?BBBB?BWBWB???WWB?BBB?BBW?B?B??W?B??BBW??WBBW???WW?BBBB?WWB?WBB???WBBB?BBW?W??BW?B??BBBBBBBWB
1 100
W?????BBB?BB?BB?????BWWWB?B???BB??????B??BWW???B??B?B???????BBB??B?BBB???B...

output:

0
WWWBBWBBBBBBBWBBWBBBWBBBBBBBWWBWBBWWBBBBBBBBBBBBBBBBBBBWBWWWBBBBBBWWBBBBBWBBBBBBBWBBWBBBWBBBBBWBBWBB
0
BWBWBWBBBBBBBBWBWBBBBWWBBBBBBBBWBBBBBBWBBBBBBWBBWBBWBBBWWBBBBBBWWBBWBBBBBWBBBBBBWBWBBBWBBBBBBBBBBBWB
0
WBBBBBBBBBBBBBBBBBBBBWWWBBBBBBBBBBBBBBBBBBWWBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBWBBWBBWBBWBBBBB...

result:

ok ok (10000 test cases)

Test #10:

score: 0
Accepted
time: 63ms
memory: 4648kb

input:

10000
100 1
W
B
B
?
B
B
B
?
B
B
B
B
W
B
B
B
?
?
B
?
B
B
?
W
B
W
?
B
?
B
W
W
?
W
?
B
?
B
B
?
W
W
B
?
B
B
?
?
W
W
B
B
?
B
B
?
B
?
?
?
W
B
W
B
?
B
W
?
?
B
B
B
B
?
B
?
W
B
B
W
B
?
W
B
B
?
B
B
?
B
?
W
?
B
?
B
B
?
B
W
100 1
?
W
?
W
?
W
W
W
W
W
B
W
?
?
B
B
?
W
?
B
W
W
W
W
?
?
?
?
W
W
B
W
W
W
W
W
?
W
W
W
?
...

output:

0
W
B
B
B
B
B
B
B
B
B
B
B
W
B
B
B
B
B
B
B
B
B
B
W
B
W
B
B
B
B
W
W
B
W
B
B
B
B
B
B
W
W
B
B
B
B
B
B
W
W
B
B
B
B
B
B
B
B
B
B
W
B
W
B
B
B
W
B
B
B
B
B
B
B
B
B
W
B
B
W
B
B
W
B
B
B
B
B
B
B
B
W
B
B
B
B
B
B
B
W
0
B
W
B
W
B
W
W
W
W
W
B
W
B
B
B
B
B
W
B
B
W
W
W
W
B
B
B
B
W
W
B
W
W
W
W
W
B
W
W
W
B
W
B
W
B
B
W
B
...

result:

ok ok (10000 test cases)

Test #11:

score: 0
Accepted
time: 88ms
memory: 4888kb

input:

1000
100 10
WWWB?WWW?W
W????????W
WB?W??WW?W
WBB?WWW??B
?WWWW?WW?W
?WWWW?W?WB
?B??W?W???
WW?W?BWWW?
WW?B?W?W?W
????WW??W?
BWB??WWWW?
W??W??WW??
W?WBB??WWW
?WWBBWW?WW
?WBWW?B???
???WWW???W
??WW?WWW??
????W?BW?W
???W?W?W?W
?WW?WW?WB?
BW??WW?WW?
WB?WWWWW?W
??BWW??W?W
W??B?WWWW?
WWW?W??WWW
BBBW??W?W?
??...

output:

335
WWWBWWWWBW
WWBWBWBBWW
WBWWWBWWBW
WBBBWWWBWB
BWWWWBWWBW
BWWWWBWBWB
WBWBWBWWBW
WWBWBBWWWB
WWWBWWBWBW
WBWBWWWBWB
BWBWBWWWWB
WBWWWBWWBW
WBWBBWBWWW
BWWBBWWBWW
BWBWWBBWBB
WBWWWWWBWW
BWWWBWWWBB
WBWBWBBWBW
BWBWBWBWBW
BWWBWWBWBW
BWBWWWBWWB
WBWWWWWWBW
BWBWWBBWBW
WBWBBWWWWB
WWWBWBBWWW
BBBWBWWBWB
WBWBWWBWBW...

result:

ok ok (1000 test cases)

Test #12:

score: 0
Accepted
time: 76ms
memory: 4548kb

input:

1000
10 100
BBWB??W??B?BWB?BBB??WWWW?B???WBB??WW???WWBW?B??W??BW?BWBBBW?BWBW?WBW?B?WWB??B?B?BBWWWBBBBW?BB???B?WB
??????WWWBWBBB??W??WW??BWBW??W??????WWWB?B??B?????W?B?????W??BBBBWBW??BWWWB???WBWB?BB?WW?B????W?WWB?
WB?BBBW?B??BB?WWW?B??WBB??W?BBW??BB??BB???BB??B??WB??W?B?B?WWWWW?BB??W?W?WBB??B?WWBBB?...

output:

330
BBWBWBWBBBBBWBWBBBWBWWWWBBBWBWBBWBWWBBBWWBWBBWBWBWBWWBWBBBWWBWBWBWBWWBWWWBWBBWBWBBWWWBBBBWWBBWBWBBWB
BWBWBWWWWBWBBBBWWWBWWBWBWBWBWWBWBWBBWWWBWBBWBBWBWBWBBWBWBWWBWBBBBWBWBWBWWWBWWBWBWBWBBWWWWBBWWBWBWWBW
WBWBBBWBBWBBBBWWWBBWBWBBBWWWBBWBWBBBWBBWBWBBWWBWBWBWBWBBWBBWWWWWWBBBWWBWBWBBBWBWWWBBBBBWWBWBWW...

result:

ok ok (1000 test cases)

Test #13:

score: 0
Accepted
time: 82ms
memory: 5836kb

input:

100
100 100
?WW?WW??WWW??BBW??WW??W???W?W?W?????W?W?BWBW??WBW????W??BB??BW?W??W????WBW?????WWB??BWW????W??W??WW?
B?????WW???B?BWWWB?WWW?WB?BB??????W??W?BWWW?BB??WWBWB?WWW????WW?W??BB?BBWB?W????W???BWWW??BBWWW???BW
W?BW??????WBB?B????W?BBW????BBW????W?W?????B?B??WW??????WWWWW?W??WW?WBW??W??W????BWWB?...

output:

4352
BWWBWWBBWWWWBBBWBWWWBBWBWBWBWBWWBWBWWBWWBWBWBBWBWBWBWWBBBBWBBWBWBWWBWBWWBWWBWBWWWBWBBWWBWBWWBBWWBWWB
BBWBWBWWBWBBWBWWWBWWWWBWBWBBBWBBWBWBWWBBWWWBBBBWWWBWBBWWWWBWBWWBWBBBBWBBWBBWBWBWWWBWBWWWBWBBWWWBWBBW
WWBWBWBBWBWBBWBWBWBWBBBWWBWWBBWWBWBWBWWBWBWBWBWBWWBWBWBWWWWWWBWWBWWBWBWWBWWBWBWBWBWWBWWBBBWBW...

result:

ok ok (100 test cases)

Test #14:

score: 0
Accepted
time: 130ms
memory: 5916kb

input:

100
100 100
B?B?W?W??BWWW?BWW??W?W??????BBB?WW??WBBWWBWBWBWW?BB?WB?WBWWWBWWB?W??W?W?BW?WW??W??W??W??W?BW??W?WBB?
W?WW???BBWBWWW?B?WBWWWBW?????W????W?WBWWWWWW??W?WW?W?BWB?W?B?W??BB?BW?BBWWW??BWWW?WW?B???W??W?WWB?WW
????WW??BW?B?BB???WWW?WWBBW?W?WBB?W?W??????B?BWWWWW??WWB?WW???W?BBB??W?BW?W??BW??WWWWW...

output:

3558
BWBBWBWBWBWWWBBWWBWWBWWBWBWBBBBBWWBWWBBWWBWBWBWWBBBBWBBWBWWWBWWBWWBWWBWWBWBWWWBWBWWBWWBWWBBWBWWBWBBB
WBWWBWBBBWBWWWWBBWBWWWBWBWBWBWBWWBWBWBWWWWWWBWWBWWBWBBWBWWBBWWBWBBWBWWBBWWWBWBWWWBWWBBWBBWWBWBWWBWWW
BWBWWWBWBWWBWBBWWBWWWBWWBBWBWBWBBWWBWWBBBWBBWBWWWWWBWWWBBWWBWBWBBBBWBWWBWBWWBBWWBWWWWWBWWBWBW...

result:

ok ok (100 test cases)

Test #15:

score: 0
Accepted
time: 184ms
memory: 6264kb

input:

100
100 100
?BBWBBBB?BBB????BBBWWB???B?BBWBWB?BBBBBBB?W?B?BBB?W?WBBWWBBB?B?B?BB?BB?BBBBBWB?WWBBB?BBBWWB?BB???B?B
B??BBBB????BBBBBWWBBBB??BBW?B?W??BBB?B?BB?BBB??B?B?BWBBWBB?BB?BBBB?BBBBBBWBBWBBBBW?BBBBWBBBWWBBBBBB?
?BBBBWB??B?BB?BB?B?BB?BWB?BBBBBWW?WBBB?BBBWB?B??W??BB?B???BB?B?W?B?BWB?BWWB?WB?WBBB?B?...

output:

2448
WBBWBBBBWBBBBBBWBBBWWBBWBBBBBWBWBWBBBBBBBBWBBBBBBWWBWBBWWBBBWBWBBBBWBBBBBBBBWBBWWBBBBBBBWWBBBBBBBBWB
BWWBBBBWBWBBBBBBWWBBBBWBBBWBBBWBWBBBBBBBBWBBBWBBWBBBWBBWBBWBBWBBBBWBBBBBBWBBWBBBBWWBBBBWBBBWWBBBBBBW
WBBBBWBBWBWBBWBBBBWBBWBWBWBBBBBWWBWBBBBBBBWBWBWBWBWBBWBWBWBBWBWWBBWBWBWBWWBBWBBWBBBWBBWBBBBWB...

result:

ok ok (100 test cases)

Test #16:

score: 0
Accepted
time: 94ms
memory: 5984kb

input:

100
100 100
W??W?BB??WBBBWB?BBW?B???WBB?BW?B???W?BBBWBW?BBB?WWBWWW?BBW?BWB??WBBWB?BWW??BBW?BWBBB?BWBBBBWB??BBB?B
WBW??BWWB?WW?BBBWWBBB?B?WBW??B?BWBW??WWB?BBWWBBB??BB??BB?B?WBB??BBWWBW?B???BWB?WWBB?B?BBBBW??BBBBWW?
???BB?WW?BBBBB??WW??B?B?WB?B?B?BWWB?B?BBWBWWWBBW?BBB?W?B??BB?WBBW?WB?WBBWW?B?BB?WB?WW?...

output:

3208
WWBWBBBBWWBBBWBWBBWBBBWBWBBWBWBBBWBWBBBBWBWBBBBBWWBWWWBBBWBBWBBBWBBWBBBWWBWBBWBBWBBBWBWBBBBWBWBBBBBB
WBWBWBWWBBWWWBBBWWBBBWBWWBWBWBWBWBWBWWWBBBBWWBBBWBBBWBBBWBWWBBWWBBWWBWWBBWBBWBWWWBBWBWBBBBWBWBBBBWWB
BWBBBWWWBBBBBBWBWWWBBWBBWBWBWBWBWWBWBWBBWBWWWBBWBBBBBWBBBWBBWWBBWBWBWWBBWWBBBBBBWBBWWBBWBWBBB...

result:

ok ok (100 test cases)

Test #17:

score: 0
Accepted
time: 102ms
memory: 6000kb

input:

100
100 100
??B????B??W???BB????BW???B??W??????B????B???????????????BB??????WB???BW???W??W?????WB??W???BWB?????W
?W?????BBB?B?W???B?WBBB???????????WBBW?W?B??????W??WBW?????????BWW?BBB????BBB???B???B?W?W????????B?B
B??????B????B????B????WB?BW???????W??W???????W???BB??????????W???W?B??WB??BB???WB??B??...

output:

5779
WBBWBWBBBBWWBBBBBWWBBWWBWBWBWBWBWBBBWBWBBWBWBWBWBWBBWBWBBBWBBWBWWBWBBBWBWBWBBWWBWBWWBWBWBWBBWBBWBWBW
BWWBWBWBBBWBWWWBWBBWBBBWBWBWBWBWBWWBBWBWWBWBWBWBWBWWBWBWBWBWWBWBWWBBBBBWBWBBBWBWBWBWBBWBWBWWBWWBWBWB
BWBWBWBBWWBWBWBWBBWBWBWBWBWBWBWBWBWBWWWBBWBWBWBWBBBWBBWBWBWBBWBWBWBBBWWBWBBBWBWWBBWBBWBWBWBBW...

result:

ok ok (100 test cases)

Test #18:

score: 0
Accepted
time: 102ms
memory: 5736kb

input:

100
100 100
WW??W?BB??BB?BW???BW???W?W?W???B?WBW??BWB?BW????B?W?????W?BWBBWB????BWW??W?WWWBBW?WBW?????BBWBWBWWWB
W????W?WWWW???BBBBWWBBBBWB?WBBWBBW?BBWBWWB???BWWBWW?WW??BWBWWW?W???WB?WWW??BWW??W?W?B?WB?WBWB??B????
BBBB??BBWWB?BB?W???WWWWW??WWWBBBW????W????WB?W??WWB??WW?BWWBB?B?????WWB?BBBW??B?B??WWW...

output:

3677
WWBBWBBBBBBBWBWBBWBWBBBWBWBWBWBBBWBWWBBWBWBWBWBBBBWWBBWBWBBWBBWBWBWBBWWBBWBWWWBBWBWBWBBWBBBBWBWBWWWB
WBWWBWBWWWWWBWBBBBWWBBBBWBWWBBWBBWWBBWBWWBWBWBWWBWWBWWBWBWBWWWBWBWBWBBWWWBWBWWWBWBWWBWWBWWBWBWBBWWBW
BBBBWBBBWWBWBBWWWBWWWWWWBWWWWBBBWBBWBWBWBWWBBWBBWWBWBWWBBWWBBWBBWBWBWWBWBBBWBBBWBWBWWWWBWWBBB...

result:

ok ok (100 test cases)

Test #19:

score: 0
Accepted
time: 104ms
memory: 5952kb

input:

100
100 100
??BB?BB?B?W???BBB?????B?BB?BB?BWBB????W?WBB?W?BB?????????B????B?BB???B?BBBB???B?B?B??BB?BB?W??BB?BBB
BB?BBWB??B?B?BB???BB???BBB??B?BBBB?BB?B??BBB?B???????B??BB??B????BB?B??????BBBBBW?B?B???B????BBB???B
B?BB??B?B??BBB??W????B?BB?BB???BB??BB???BBBB??BB???B?BB??B?BB?BB??B??B??B?B??B??B?B??B...

output:

4003
BWBBWBBWBWWWBWBBBBWWBWBWBBWBBBBWBBBWWBWBWBBBWWBBWBWBWWBBWBWBWWBWBBWBWBWBBBBWBBBWBWBBWBBWBBBWBWBBBBBB
BBWBBWBBWBWBWBBWBWBBWBWBBBBWBWBBBBWBBWBWBBBBWBWWBWBWBBWWBBBWBBWBWBBWBWBWWBWBBBBBWBBWBWWBBBWBWBBBWBWB
BWBBWBBWBWBBBBWBWBWBWBWBBBBBWBWBBBWBBBWBBBBBBWBBWBWBWBBBWBWBBWBBBWBBWBWBBWBWBBBWBWBBWBBWBWBWB...

result:

ok ok (100 test cases)

Test #20:

score: 0
Accepted
time: 123ms
memory: 5748kb

input:

100
100 100
BW?B?B??BB??WWWB?W?B??WBWBB?BWBWB?B?WBBBBBB?B????BBWBBBWWBBB?BBB?WBBBBB?WWBBBWWWB??BBWB?BBWBWWBW?WWB
W??BBWBWBW???W??BWBB?BWBBBWWWBW?BWWWB?B?BBWBWB?B??B?WBBW?W?W?BB?B??WWB?BB?BBBWBB?BBB?WBWWBWBWBWB??BB
BB?WBW??WB?W?BW?WB?B?WB?W?B?B?BW?B??WB?WB?WW???WBBWBWBW?B???W??B??WB??B?BBBWBB?WWW???B...

output:

2489
BWBBWBWBBBWBWWWBWWBBBWWBWBBBBWBWBBBBWBBBBBBWBWBWBBBWBBBWWBBBWBBBWWBBBBBWWWBBBWWWBWBBBWBBBBWBWWBWBWWB
WBWBBWBWBWBWBWBWBWBBWBWBBBWWWBWBBWWWBWBBBBWBWBWBWWBBWBBWBWBWBBBWBWBWWBWBBBBBBWBBWBBBWWBWWBWBWBWBWBBB
BBBWBWWBWBWWWBWBWBWBBWBWWWBBBWBWWBBBWBWWBWWWBWBWBBWBWBWBBBWBWBWBWBWBBWBWBBBWBBWWWWBWBBWBWBWBB...

result:

ok ok (100 test cases)

Test #21:

score: 0
Accepted
time: 132ms
memory: 5860kb

input:

100
100 100
?WBWB?WWWWW??W?????BBW?WW?WWW???WW???BW?WWW???WWW??B?B?W?B?W??WBWW??WWBWBW?WWW?B???WW????WW?W?WW?WWW
WWW??BWW?WW?WW?WW???WWBWB?B?W?BW?W?BWWW?W???WWWW?WBWBBW?W?B?B?WB?B?W?W?BBW??W?W??????W?BWW?W???WWWW?
??WWWW?W?BW????B?W??BWW???W?W??B??WWB?W?WW????W?W?B?W??BBWB??WWBW?WW?W???W??B??WBWWW??...

output:

3481
BWBWBWWWWWWWBWWBBWBBBWBWWBWWWBWBWWBWBBWBWWWBBBWWWBWBWBBWBBWWWBWBWWBBWWBWBWBWWWBBBWBWWBWWBWWBWBWWBWWW
WWWBWBWWBWWBWWBWWBWBWWBWBWBWWWBWBWWBWWWBWBBWWWWWBWBWBBWBWWBWBWWBBBWWBWWBBWWBWBWBWBWBBWBBWWBWBWBWWWWB
BWWWWWBWWBWWBBWBBWBWBWWBWBWBWBWBWBWWBBWBWWWBWBWBWBBBWWBBBWBBWWWBWBWWBWWBWWBWBWBWBWWWWBWBWBWBW...

result:

ok ok (100 test cases)

Test #22:

score: 0
Accepted
time: 105ms
memory: 4388kb

input:

10000
10 10
??????????
?W?W??????
??????B???
???????W??
??????B???
??????????
?????B???W
??????????
??????????
???????W??
10 10
???W?WW???
?WWBB?WWBB
?WB??BBWBW
?W?WW?WW?B
BB???B?W??
?B?BWB??BW
BBWBWB?BB?
??BB?BB???
B?W??W????
?BBBB??BW?
10 10
??B?B??W?W
?BBBBW??B?
BBWWBB?B?B
??W??W??B?
B?W?BB???W
?...

output:

71
WBWBWBWBWB
BWBWBWBWBW
WBWBWBBBWB
BWBWBWBWBW
WBWBWBBBWB
BWBWBWBWBW
WBWBWBWBWW
BWBWBWBWBW
WBWBWBWBWB
BWBWBWBWBW
21
WBBWBWWBWB
BWWBBWWWBB
BWBWWBBWBW
BWBWWBWWWB
BBWBBBBWBW
BBBBWBWBBW
BBWBWBWBBW
BWBBWBBWWB
BBWWBWBWBW
BBBBBBWBWB
45
BWBBBBWWBW
WBBBBWBWBW
BBWWBBWBWB
WBWBWWBWBW
BWWWBBWBWW
WBWWBBBWBB
BWBBW...

result:

ok ok (10000 test cases)

Test #23:

score: 0
Accepted
time: 106ms
memory: 4656kb

input:

10000
10 10
WBWWWWBBWW
WBWWW?BWWW
WWWBBBBWWB
BBBBWBBBWW
WBBBBBWBWW
W?BBBBWWWB
BWBBWBBWBB
BBB?WBWWWB
WBWWBBWWWW
BBWWBBBWBB
10 10
B?WW??W??B
B????WWWBB
?BB?W?WWW?
WWW?W?W??W
W?BB??BBW?
B??BW???BB
WWWWW??BW?
?B?BB???W?
??W???WW??
WBB???W???
10 10
??BW?W?WW?
?BBBBBBBW?
?BBBB?BWW?
B?BBBW???B
BWBBWWW?BB
W...

output:

2
WBWWWWBBWW
WBWWWBBWWW
WWWBBBBWWB
BBBBWBBBWW
WBBBBBWBWW
WBBBBBWWWB
BWBBWBBWBB
BBBBWBWWWB
WBWWBBWWWW
BBWWBBBWBB
29
BBWWWBWBWB
BWBWBWWWBB
WBBBWBWWWB
WWWBWBWWBW
WBBBBWBBWB
BWBBWBWWBB
WWWWWBWBWB
WBBBBWBBWB
BWWBWBWWBW
WBBWBWWBWB
9
BWBWBWBWWB
WBBBBBBBWB
WBBBBBBWWB
BWBBBWWBWB
BWBBWWWWBB
WBWBBWBWBB
BWWWWBW...

result:

ok ok (10000 test cases)

Test #24:

score: 0
Accepted
time: 154ms
memory: 4960kb

input:

1000
100 10
W???W?BBW?
WW??BWWW??
WBB?B?W?W?
W?BB???WWB
?WWB?WW??W
W??W????WB
BW??BBWBB?
BB???W?WBB
???WBW?WW?
?WBB?WBB??
?WB?BB?WBW
W?B?WB?WB?
?BB?WWWWBB
WB??BBWW?W
WB?BW?BWBB
??W?WBWWW?
??W?BBWBB?
WW??WWW?B?
BW??BB??W?
BW??W?W?WW
??BBWW???W
BB??BBWWBW
BBW??BBWWW
??B?WBW?B?
?B?BB?B??W
W??BW?BWBW
WW...

output:

240
WBWBWBBBWB
WWBWBWWWBW
WBBWBWWBWB
WBBBWBBWWB
BWWBBWWBBW
WBBWWBBWWB
BWBWBBWBBW
BBWBWWBWBB
WBWWBWBWWB
BWBBWWBBWB
BWBWBBWWBW
WBBBWBBWBB
BBBBWWWWBB
WBBWBBWWBW
WBWBWWBWBB
BWWBWBWWWB
WBWWBBWBBW
WWBBWWWBBW
BWBWBBBWWB
BWWBWBWBWW
WBBBWWBWBW
BBBWBBWWBW
BBWBWBBWWW
BWBWWBWBBB
WBWBBWBWBW
WWBBWBBWBW
WWWWBWBBBB...

result:

ok ok (1000 test cases)

Test #25:

score: 0
Accepted
time: 124ms
memory: 4672kb

input:

1000
10 100
?????????BBW??????B??WWWW??WW????????WW???W?WBBB????????W?B?W???W?W??W???????B?BW?????B??????B??????
??????B?W??W?W??B?????WBWB?W?????????????WWB????WWW??????W?????????????????W????W?W????W???W?W??B???
BB?B???WWW?W?WBW????????WW???B???B???BB?????WW?????????BB?????B??B??W????B?????B???BW?...

output:

585
WBWBWBWBBBBWWBWBWWBWBWWWWWBWWBWBWBWBWWWBWBWBWBBBBBBBWBWBWBBWWWBWWBWBWWWBWBWBWBWBWWBBWBBBWBWBWBWBWBWB
BWBWBWBWWBWWBWBWBBWBWBWBWBWWBWBWBWBWBWBWBWWBBWBWWWWWBWBWBWWBWBWBWWBWBWBWBWBWBWBWWBWWBWBWBWBWBWBWBWBW
BBWBWBWWWWBWBWBWBWBWBWBWWWBBWBWBWBWBWBBBWBWBWWWBWBWBWBWBBWBWBWBWBBWBWBWBWBWBWBWBBWBBWBWBWBWBWB...

result:

ok ok (1000 test cases)

Test #26:

score: 0
Accepted
time: 641ms
memory: 6764kb

input:

100
100 100
????W?????W?W????B???W???B????????????????????????????????WW????W?W??????W?BB??B??????????WB????W???
?????B??W???????????????B?????????B????????????????????????W??????????????BW??????B?????????????????
???B????????????????B????????????????????B??????B??????W?BB?????????????????B??????W??...

output:

7761
WBWBWWBWBBWBWBWBWBBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWBWWWBWBWBWBWBWBWWWBBWWBWBWBWBWBWBWBWBWBWBWB
BWBWBBWBWWBWBWBWBBWBWBWBBBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBBWBWBWBWBWBWBWBWBWBWWBBWBWBWBWBWBWBWBWBWBWBW
WBWBWBWBWBWBWBWBWWBWBWBWBWBWBWBWBWBWBWBWBBBWBWBWBWBWBWBWWBBBWBWBWBWBWBWBWBWWBWWBWBWWWBWBWBWBW...

result:

ok ok (100 test cases)

Test #27:

score: 0
Accepted
time: 752ms
memory: 6768kb

input:

100
100 100
BBBW??W??WBWBW?B????B???BWWB?BB??BB?WWBW?W?????BBBWB?BBBB?WBBBW??WWWW????B?W?B??W?W?BB??W??W?BBB??BB
WWB??WW??B?W?WWWWWW?BWW??BW??BBBWWBB?W?W?BBWWWWBWBW??B?WB?B?BBB?W?WWWB???W??W?BB?BWWBW?WW?BW???W??WB
WBBBWW?W?BW????W??B?BBW?B??WW?BB??B?WWW????W?WW??BW??BBW?BBB?BB??WW??W???WWB??WWWW?BB?...

output:

3201
BBBWWBWWBWBWBWBBBBBWBBBWBWWBWBBWBBBBWWBWBWWBBBBBBBWBWBBBBBWBBBWWBWWWWWBWBBWWBBWBWBWBBBWBWBWWBBBBBWBB
WWBWBWWBWBWWBWWWWWWBBWWBWBWWBBBBWWBBBWBWWBBWWWWBWBWWBBBWBWBWBBBBWBWWWBWBWWBWWWBBBBWWBWBWWWBWWBWWWBWB
WBBBWWBWWBWBWBBWBWBWBBWWBWBWWWBBBWBWWWWBWBWWBWWBWBWBWBBWWBBBWBBWBWWWBWBWBWWBBBWWWWBBBBWBWWBWB...

result:

ok ok (100 test cases)

Test #28:

score: 0
Accepted
time: 1202ms
memory: 6984kb

input:

100
100 100
?WBWW?W???WWWW?WWWB?BBBBBWWWWBBWWB??B?BB?BWBBWBBBWWWBB?BW?BWBBB??BB???BWBBB?BW?WWBWWWWB??B?BWWWBWBBW
WWW?W?WWWW???BBB??????B?BWBWBB?W??B?W?WWWBWBW?W??WW?B?WBBWW?WWWW??W???BWWB?WWW?W?BBBW??WBBWBW??WW?B?
??BWW?WBBBWBWW?W?WWWW?B???BBBBWBBBBW??W?WWW?BW?BWBWWBBWBBB?BBWBBBB?WBBBBWW?WWWWW??W?WB...

output:

1504
BWBWWBWBBBWWWWBWWWBWBBBBBWWWWBBWWBWWBWBBBBWBBWBBBWWWBBBBWBBWBBBBWBBWBWBWBBBBBWBWWBWWWWBBWBBBWWWBWBBW
WWWBWBWWWWBWBBBBWBWBWBBWBWBWBBBWBWBBWBWWWBWBWBWWBWWBBBWBBWWBWWWWBWWBWBBWWBWWWWBWWBBBWBWWBBWBWBBWWBBB
BWBWWBWBBBWBWWBWBWWWWBBBWBBBBBWBBBBWBWWBWWWWBWBBWBWWBBWBBBWBBWBBBBBWBBBBWWBWWWWWBWWBWBWWWWBBB...

result:

ok ok (100 test cases)

Test #29:

score: 0
Accepted
time: 16ms
memory: 4764kb

input:

100
100 100
WWWWBBBWWBBBW?BBW?BBB?WWBBB?WWBBBWBBBWBBWBWBWWWWWBBWWWBWBBWWBWBW?BBWBBWBW?WWWBBWWWWWWWW?BW?BBWBBW??B
BWWWWBBB?WBBWW?WWB?BBWBB?BBBBBBBWB?WWBWW?WWBBWWWWBBBWBWBWWWBWBWBWWBWWWBBB?B??WBWWWBBBBBBWBBBBW?WB?WB
B?WBWBBBBWWWWBBWWWB?BBWB??WWBWBB?WBBBBBWWBWW?WBBBBBBBWWBWWWWW?BBWBBB?BBB?WBWBB?BBB??BB...

output:

1685
WWWWBBBWWBBBWBBBWWBBBBWWBBBBWWBBBWBBBWBBWBWBWWWWWBBWWWBWBBWWBWBWBBBWBBWBWBWWWBBWWWWWWWWWBWBBBWBBWWBB
BWWWWBBBBWBBWWBWWBWBBWBBWBBBBBBBWBWWWBWWBWWBBWWWWBBBWBWBWWWBWBWBWWBWWWBBBWBBBWBWWWBBBBBBWBBBBWBWBBWB
BWWBWBBBBWWWWBBWWWBWBBWBBWWWBWBBBWBBBBBWWBWWBWBBBBBBBWWBWWWWWWBBWBBBBBBBWWBWBBWBBBWBBBBBBWBWB...

result:

ok ok (100 test cases)

Test #30:

score: 0
Accepted
time: 40ms
memory: 4748kb

input:

100
100 100
BBBWW?BWWW?WB?W?WW?????B?WBWWWBWWWBW?BWW?B???B?WWW??BB???BWB??BBB??WWW?W?W??BBBWBWB?W?BBBB??W??B?WWW
?B?WW????W?WB?W??B???WWW?W?B?WBBBWBWB?W?WWWBW?BBWWBBBW?B?W?WB?WWB?BWWWWW??WBWB?B?WBW??WB?WBWWW???B?B
??BWW?WWBWWB??WB?BW?WWBWWW??W????W???W?WB?BWBB?BWBBB?BW?W?WWWWBWBW?WBWBWBW??BBWWW?WBB?...

output:

2809
BBBWWWBWWWBWBBWBWWWBWBBBWWBWWWBWWWBWWBWWBBBWBBWWWWBBBBWBWBWBWWBBBBWWWWBWBWBWBBBWBWBBWBBBBBWBWBWBWWWW
WBWWWBWBWWBWBWWWBBBWBWWWBWWBBWBBBWBWBWWBWWWBWWBBWWBBBWBBBWBWBBWWBWBWWWWWWBWBWBWBWWBWBWWBBWBWWWBWBBBB
BWBWWBWWBWWBWBWBWBWBWWBWWWBWWBWBWWWBWWBWBWBWBBWBWBBBWBWBWBWWWWBWBWBWBWBWBWBWBBWWWBWBBBWBWWBWW...

result:

ok ok (100 test cases)

Test #31:

score: 0
Accepted
time: 85ms
memory: 4992kb

input:

100
100 100
?BB???B?BBB?WB??B?B??B?BW??BB?BWWW?B?B???WB??B??BB?BBBB?BB????BWB?B??BBBBBBBBBW??BB?BB?B??BBW?B??B?W
?BBB?B?B?BBBBBB?B????B?BB????B??B??BB??BBB?W?BB??BBBBBBB??B??BBB???B?????B?WBB?B??BBBBB?BBBB?BB?B???
BBBW??B??B????BB??BB????B??B??BBBB?BB?B??B???WBB??B?BWB?B?B?B?B?BB?BBB?BWB?????BW???BB...

output:

3817
BBBWBWBWBBBBWBWBBWBWBBBBWBWBBWBWWWBBWBBWBWBBWBWBBBBBBBBWBBWWBWBWBWBWBBBBBBBBBBWWBBBBBBWBWBBBWBBBWBWW
BBBBWBWBWBBBBBBWBBWBWBWBBWBWWBWBBBWBBWWBBBWWBBBWBBBBBBBBWWBBWBBBWBWBWWBWBBBWBBWBWBBBBBBWBBBBWBBWBWBB
BBBWBWBWBBWBWBBBWWBBBWBWBBWBBWBBBBWBBBBWWBWBWWBBWBBWBWBWBBBWBWBWBBBBBBWBWBBWBWBBWWBWBBBWWBBWB...

result:

ok ok (100 test cases)

Test #32:

score: 0
Accepted
time: 212ms
memory: 5604kb

input:

100
100 100
??B?????????WBWB?B??B????????WB?WW????WBW???W??????????B???BWW?????W??W?B?????W???B????WB???B?W?W???
W?BW??W??W???WWB???BWBW?WB??WWWB?B?WB??B???BWW??B??B????????B??BB??B?????B??W?W??W?B???W?????B????BW
??W????B???BB????????????WB????WB???B??BBB????B???WWB?????WW??B????BBW??W?W???BW?W?W??...

output:

5861
BWBBBWBBWBWBWBWBWBWWBWBWBWBWBWBWWWBBWBWBWWBWWBWBWBWWBBWBWBWBWWBWBWBWBWWWBWBWBWWWBBBWBBWWBWBWBWWBWBWB
WBBWWBWWBWBWBWWBBWBBWBWBWBWBWWWBWBWWBWBBBBWBWWBWBWBBWWBWBWBWBBWBBBWBWBWBWBWBWBWBWWWBWWBWWBWBWBBWBWBW
BWWWBWBBWBWBBBWBWBWWBWBWBWBWBWBWBWBWBWBBBBBWBWBBWBWWBBWBWBWWBWBWBWBBBWBWWBWWBWBWBWBWBBWBBWBWB...

result:

ok ok (100 test cases)

Test #33:

score: 0
Accepted
time: 7220ms
memory: 6412kb

input:

100
100 100
?????W???????????????????B????W????W????????????WB??W?????????????W?????????????B??????????W?BW?W???
W?WW????BB????????????????W????????????????????????W????????????????W?W???????????????W????W????????
????????????W??????????WW????????????????????????W??????W???????B?????????B????W??????...

output:

8073
BWBBBWBWBWBWBWBWBWBWBWBWWBBWBWWWBWBWBWBWBWBWBWBWWBWBWBWBWWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWWBWWWBWBWBWB
WBWWWBWBBBWBWBWBWBWBWBWBBWWBWBWBWBWBWBWBWBWBWBWBBWBWBWBWBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBBWBWBWBWBWBW
BWBWBWBWBWBWWWBWBWBWBWBWWBBWBWBWBWBWBWBWBWBWBWBWBWWBWBWBWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWBWBW...

result:

ok ok (100 test cases)

Test #34:

score: -100
Time Limit Exceeded

input:

100
100 100
???B??B????????B?W??????B??????????????B???????????W?????????????????????????W??????????????????????
?????????????????????????????????????B????????????????????????????W??????W???B??????????????????????
??????????????????W????????????????????????????????????????????W??????????????????????...

output:

8988
BWBBBWBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWB
BWBWBWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB...

result: