QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359999#5071. Check Pattern is GoodSlongodAC ✓6280ms7120kbC++144.5kb2024-03-21 08:56:332024-03-21 08:56:34

Judging History

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

  • [2024-03-21 08:56:34]
  • 评测
  • 测评结果:AC
  • 用时:6280ms
  • 内存:7120kb
  • [2024-03-21 08:56:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
namespace Slongod{
const int N = 5e4+7 , inf = 0x3f3f3f3f;
namespace wll
{
	int econt , s , t , head[N] , hu[N] , dep[N];
	struct EDGE{int to , nxt , w;}edge[N*10];
	inline void _add(int x , int y , int w){edge[++econt].to = y; edge[econt].nxt = head[x]; head[x] = econt; edge[econt].w = w;}
	inline void add(int x , int y , int w){_add(x , y , w); _add(y , x , 0);}
	inline bool bfs()
	{
		for (int i = 0; i <= max(s,t); i++){dep[i] = -1; hu[i] = head[i];}
		queue <int> q; q.push(s); dep[s] = 0;
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = head[u]; i; i = edge[i].nxt) {
				int v = edge[i].to , w = edge[i].w;
				if (w and dep[v] == -1) {
					dep[v] = dep[u] + 1; q.push(v);
				}
			}
		} return dep[t] != -1;
	}
	int dfs(int u , int f)
	{
		if (u == t){return f;} int used = 0;
		for (int &i = hu[u]; i; i = edge[i].nxt) {
			int v = edge[i].to , w = edge[i].w;
			if (dep[v] == dep[u] + 1 and w) {
				int tmp = dfs(v , min(f-used , w));
				edge[i].w -= tmp; edge[i^1].w += tmp; used += tmp;
				if (f == used){break;}
			}
		} if (!used){dep[u] = -1;} return used;
	}
	inline int dinic(){int re = 0; while(bfs()){re += dfs(s , inf);} return re;}
	inline void init(int S , int T){s = S; t = T; for (int i = S; i <= T; i++){head[i] = 0;} econt = 1;}
}
int n , m , s , t , ans , flag[N] , output[105][105];
const int dx[4] = {-1 , -1 , 0 , 0};
const int dy[4] = {-1 , 0 , -1 , 0};
#define id(x , y) ((x - 1) * (m - 1) + y)
#define rid(x , y , opt) (id(x , y) * 2 - opt)
inline bool cmp(int x , int y){return 1 <= x and x < n and 1 <= y and y < m;}
void main()
{
	int T; cin >> T;
	while(T--) {
		cin >> n >> m; ans = (n - 1) * (m - 1) * 2;
		s = 0; t = rid(n-1 , m-1 , 0) + 1;
		wll::init(s , t);
		for (int i = 1; i <= id(n-1,m-1); i++){flag[i] = 0;}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				char a; cin >> a;
				if (((i + j) & 1) and a == 'W'){a = 'B';}
				else if (((i + j) & 1) and a == 'B'){a = 'W';}
				if (a != '?'){output[i][j] = (a == 'W' ? 1 : 2);}
				else{output[i][j] = 0;}
				for (int k = 0; k < 4; k++) {
					int tx = i + dx[k] , ty = j + dy[k];
					if (!cmp(tx , ty)){continue;}
					if (a == 'W'){flag[id(tx,ty)] |= 1;}
					if (a == 'B'){flag[id(tx,ty)] |= 2;}
				}
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < m; j++) {
				wll::add(rid(i,j,1) , rid(i,j,0) , inf);
				if (flag[id(i,j)] == 0) {
					wll::add(s , rid(i,j,1) , 1);
					wll::add(rid(i,j,0) , t , 1);
				} else if (flag[id(i,j)] == 1) {
					ans--;
					wll::add(s , rid(i,j,1) , 1);
				} else if (flag[id(i,j)] == 2) {
					ans--;
					wll::add(rid(i,j,0) , t , 1);
				} else {
					ans -= 2;
				}
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < m; j++) {
				if (flag[id(i,j)] == 3){continue;}
				if (i > 1) {
					for (int k = j; k <= j+1 and k < m; k++) {
						if (flag[id(i-1,k)] == 3){continue;}
						wll::add(rid(i,j,1) , rid(i-1,k,0) , inf);
						wll::add(rid(i-1,k,1) , rid(i,j,0) , inf);
					}
				}
				if (j > 1) {
					for (int k = i; k <= i+1 and k < n; k++) {
						if (flag[id(k,j-1)] == 3){continue;}
						wll::add(rid(i,j,1) , rid(k,j-1,0) , inf);
						wll::add(rid(k,j-1,1) , rid(i,j,0) , inf);
					}
				}
				if (i > 1 and j > 1 and flag[id(i-1,j-1)] != 3) {
					wll::add(rid(i,j,1) , rid(i-1,j-1,0) , inf);
					wll::add(rid(i-1,j-1,1) , rid(i,j,0) , inf);
				}
			}
		}
		cout << ans - wll::dinic() << '\n';
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < m; j++) {
				if (wll::dep[rid(i,j,1)] == -1 and !(flag[id(i,j)]&1)) {
					for (int tx = i; tx <= i+1; tx++) {
						for (int ty = j; ty <= j+1; ty++) {
							output[tx][ty] = 2;
						}
					}
				}
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < m; j++) {
				if (wll::dep[rid(i,j,1)] != -1 and !(flag[id(i,j)]&2)) {
					for (int tx = i; tx <= i+1; tx++) {
						for (int ty = j; ty <= j+1; ty++) {
							output[tx][ty] = 1;
						}
					}
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (((i+j)&1) and output[i][j] == 1){output[i][j] = 2;}
				else if (((i+j)&1) and output[i][j] == 2){output[i][j] = 1;}
				if (output[i][j] == 1){cout << 'W';}
				else{cout << 'B';}
			} cout << '\n';
		}
	}
}

}int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.in" , "r" , stdin);
	#endif
	ios :: sync_with_stdio(0);
	cin.tie(0) , cout.tie(0);
	return Slongod :: main(),0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 34ms
memory: 3900kb

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
WBWBWWW
BWBBWWB
WBWWBWB
BBWBBWB
WWBBWWB
BWBWBWB
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: 33ms
memory: 3696kb

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
WBWB
WWBW
WBWB
BWWB
1
BW
WB
BB
4
BWBBWWB
WBWWBBW
20
WBWBWWWBW
BWBWBBWWW
WBWBBWBWW
WWBWWBWWW
WBBWBWBBW
BWBBWWWWW
WBWBWBWBW
WWWWBWWWW
BBWWWWWWB
28
WWBBWWWBWB
WBWBWBWBBW
BWBWBWBWBW
WBWWBW...

result:

ok ok (10000 test cases)

Test #4:

score: 0
Accepted
time: 30ms
memory: 3556kb

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
WBBBBWB
WWWBWBW
BBBWBBB
BBWBWWB
BWBWBBW
13
WBWWWB
WBBWBW
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: 34ms
memory: 3596kb

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
WBWWWBWWW
BWWWBWBWB
5
WBBBBBW
BWBWWWB
BBWBBBW
0
BBBWWB
0
W
W
W
B
B
W
B
23
WWBBWWBW
WWWWBBWB
BBWBWWWW
BWBWBWBW
BBWBWBWB
BWBWBWWB
BWBWWBWB
BBWBBWBW
19
WWWBWBBW
WBWWBWBW
WWBWBWBW
WWWWBWWB
WBWBWBBW
BWBBWBWB
WBWWBWWB
WWBWWBWW
WBWBWWWB
WWWWBBBB
0
WB...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 34ms
memory: 3632kb

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
WBWWWBWW
BWBWBWBB
BBWBBBBB
WBBWBBBB
2
WB
BW
WB
BB
WW
WB
0
WWBBBWBBWB
6
BWB
WBW
BWB
WBW
26
WWBBBWWBWB
WWBBWBBWBW
BWWBWBWBWW
WBWBBBBBBB
BWBBBBWBBW
BWWBBWBWBB
WWBBBWWBBB
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: 121ms
memory: 3620kb

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
WWBWBBWWWB
BBWBBWBWBW
WWBWBWWBWB
BBBWWWWBWW
WWBWWWBWWB
33
WBWWBWBWWB
BWWBWBWBWB
WBWWBWWBWB
WWBBWWBWWB
BWBBWWBWWB
BWWWBWWWBW
BWBBW...

result:

ok ok (10000 test cases)

Test #8:

score: 0
Accepted
time: 118ms
memory: 3584kb

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: 25ms
memory: 3612kb

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: 41ms
memory: 3632kb

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: 215ms
memory: 3952kb

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
WWWBBWWWBW
WBWBWBBBWW
WBBWBWWWBW
WBBBWWWBWB
BWWWWBWWBW
BWWWWBWBWB
WBWBWBWWBW
WWBWBBWWWB
WWBBWWBWBW
WBWBWWWBWB
BWBWBWWWWB
WBWWWBWWBW
WBWBBWBWWW
BWWBBWWBWW
BWBWWBBWBB
WBWWWWWBWW
BWWWBWWWBB
WBWBWBBWBW
BWBWBWBWBW
BWWBWWBWBW
BWBWWWBWWB
WBWWWWWWBW
BWBWWBBWBW
WBWBBWWWWB
WWWBWWBWWW
BBBWBBWBWB
WBWBWWBWBW...

result:

ok ok (1000 test cases)

Test #12:

score: 0
Accepted
time: 214ms
memory: 3852kb

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
BBWBWBWBBBBBWBWBBBWBWWWWBBBWBWBBWBWWBBBWWBWBBWBWBWBWWBWBBBWWBWBWBWBWWBWWWBWWBWBWBBWWWBBBBWWBBWBWBBWB
BWBWBWWWWBWBBBBWWWBWWBWBWBWBWWBWBWBBWWWBWBWWBBWBWBWBBWBWBWWBWBBBBWBWBWBWWWBBWBWBWBWBBBWWWBBWWBWBWWBW
WBWBBBWBBWBBBBWWWBBWBWBBBWWWBBWBWBBBWBBWBWBBWWBWBWBWBWBBWBBWWWWWBBBBWWBWBWBBBWBWWWBBBWBWWBWBWW...

result:

ok ok (1000 test cases)

Test #13:

score: 0
Accepted
time: 441ms
memory: 6308kb

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
BBWBWBWWBWBBWBWWWBWWWWBWBWBBWWBBWBWBWWBBWWWBBBWBWWBWBBWWWWBWBWWBWBBBBWBBWBBWBWBWWWBWBWWWBWBBWWWBWBBW
WWBWBWBWWBWBBWBWBWBWBBBWWBWWBBWWBWBWBWWBWBWBWBBWWWBWBWBWWWWWWBWWBWWBWBWWBWWBWBWBWBWWBWWBBBWWW...

result:

ok ok (100 test cases)

Test #14:

score: 0
Accepted
time: 529ms
memory: 6592kb

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
BWBBWBWBWBWWWBBWWBWWBWWBWBWBBBBWWWBWWBBWWBWBWBWWBBBBWBBWBWWWBWWBWWBWWBWWBWBWWWBWBWWBBWBWWBBWBWWBWBBB
WBWWBBWBBWBWWWWBWWBWWWBWBWBWBWBWWBWBWBWWWWWWBWWBWWBWBBWBWWBBWWBWBBWBWBBBWWWBWBWWWBWWWBWBBWWBWBWWBWWW
BWBWWWBWBWWBWBBWBWWWWBWWBBWBWBWBBWWBWWBBBWBBWBWWWWWBWWWBBWWBWBWBBBBWBWWBWBWWBBWWBWWWWWBWWBWBW...

result:

ok ok (100 test cases)

Test #15:

score: 0
Accepted
time: 527ms
memory: 6796kb

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
WBBWBBBBWBBBBBBWBBBWWBBWBBBBBWBWBWBBBBBBBBWBBWBBBWWBWBBWWBBBWBWBBBBWBBBBBBBBWBBWWBBBBBBBWWBBBBBBBBWB
BWWBBBBWBWBBBBBBWWBBBBWBBBWBBBWBWBBBBBBBBWBBBWBBWBWBWBBWBBWBBWBBBBWBBBBBBWBBWBBBBWWBBBBWBBBWWBBBBBBW
WBBBBWBBWBWBBWBBBBWBBWBWBWBBBBBWWBWBBBBBBBWBWBWBWBWBBWBWBWBBWBWWBBWBWBBBWWBBWBBWBBBWBBWBBBBWB...

result:

ok ok (100 test cases)

Test #16:

score: 0
Accepted
time: 450ms
memory: 6460kb

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
WWBWBBBBWWBBBWBWBBWBBBWBWBBWBWBBBWBWBBBBWBWBBBBBWWBWWWBBBWBBWBBBWBBWBBBWWWBBBWBBWBBBWBWBBBBWBWBBBBBB
WBWBWBWWBBWWWBBBWWBBBWBWWBWBWBWBWBWBWWWBBBBWWBBBWBBBWBBBWBWWBBWWBBWWBWWBBBWBWBWWWBBWBWBBBBWBWBBBBWWB
BWBBBWWWBBBBBBWBWWWBBWBBWBWBWBWBWWBWBWBBWBWWWBBWBBBBBWBBBWBBWWBBWBWBWWBBWWBBBBBBWBBWWWBWBWBBB...

result:

ok ok (100 test cases)

Test #17:

score: 0
Accepted
time: 520ms
memory: 6432kb

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
WBBWBWBBBBWWBBBBBWWBBWWBWBWBWBWBWBBBWBWBBWBWBWBWBWBBWBWBBBWBBWBWWBBWBBWBWBWBBWWBWBWWBWBWBWBBWBBWBWBW
BWWBWBWBBBWBWWWBWBBWBBBWBWBWBWBWBWWBBWBWWBWBWBWBWBWWBWBWBWBWWBWBWWWBBBBWBWBBBWBWBWBWBBWBWBWWBWWBWBWB
BWBWBWBBWWBWBWBWBBWBWBWBWBWBWBWBWBWBWWWBBWBWBWBWBBBWBBWBWBWBBWBWBWBBBWWBWBBBWBWWBBWBBWBWBWBBW...

result:

ok ok (100 test cases)

Test #18:

score: 0
Accepted
time: 544ms
memory: 6580kb

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
WWBBWBBBBBBBBBWBBWBWBBBWBWBWBWBBBWBWWBBWBWBWBWBBBBWWBBWBWBBWBBWBWBWBBWWBBWBWWWBBWBWBWWBWBBBBWBWBWWWB
WBWWBWBWWWWBWWBBBBWWBBBBWBWWBBWBBWWBBWBWWBWBWBWWBWWBWWBWBWBWWWBWBWBWBBWWWBWBWWWBWBWBBBWBWWBWBWWBWWBW
BBBBWBBBWWBWBBWWWBWWWWWWBWWWWBBBWBBWBWBWBWWBBWBBWWBWBWWBBWWBBWBBWBWBWWBWBBBWBBBWBWBWWWWBWWBBB...

result:

ok ok (100 test cases)

Test #19:

score: 0
Accepted
time: 495ms
memory: 6648kb

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
BWBBWBBWBWWWBWBBBBWWBWBWBBBBBBBWBBBWWBWBWBBBWWBBWBWBWWBBWBWBWWBWBBWBWBWBBBBWBBBWBWBBWBBWBBBWBWBBBBBB
BBWBBWBBWBWBWBBWBWBBWBWBBBWWBWBBBBWBBWBWBBBBWBWWBWBWBBWWBBBWBBWBWBBWBWBBWBWBBBBBWBBWBWWBBBWBWBBBWBWB
BWBBWBBWBWBBBBWBWBWBWBWBBWBBWBWBBBWBBBWWBBBBBWBBWBWBWBBBWBWBBWBBBWBBWBWWBWBWBBBWBWBBWBBWBWBWB...

result:

ok ok (100 test cases)

Test #20:

score: 0
Accepted
time: 485ms
memory: 6708kb

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
BBBWBWWBWBWWBBWBWBWBBWBWWWBBBWBWWBBWWBWWBWWWBWBWBBWBWBWWBWWBWBWBWBWBBWBWBBBWBBWWWWBWBBWBWBWBB...

result:

ok ok (100 test cases)

Test #21:

score: 0
Accepted
time: 491ms
memory: 6436kb

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
BWBWBWWWWWWWBWWBBWBBBWBWWBWWWBWBWWBWBBWBWWWBBBWWWBWBWBBWBBBWWBWBWWBBWWBWBWBWWWBBBWBWWBWWBWWBWBWWBWWW
WWWBWBWWBWWBWWBWWBWBWWBWBWBWWWBWBWWBWWWBWBBWWWWWBWBWBBWBWBBWBWWBBBWWBWWBBWWBWBWBWBWBBWBBWWBWBWBWWWWB
BWWWWWBWBBWWBWBBBWBWBWWBWBWBWBWBWBWWBBWBWWWBWBWBWWBBWWBBBWBBWWWBWBWWBWWBWWBWBWBWBWWWWBWBWBWBW...

result:

ok ok (100 test cases)

Test #22:

score: 0
Accepted
time: 135ms
memory: 3556kb

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
BWBWBWWWBW
WBWBWBBBWB
BWBWBWBWBW
WBWBWBWBWW
BWBWBWBWBW
WBWBWBWBWB
BWBWBWBWBW
21
WBBWBWWBWB
BWWBBWWWBB
BWBWWBBWBW
BWBWWBWWWB
BBBWBBBWBW
BBWBWBWBBW
BBWBWBBBBW
WBBBWBBBWB
BWWWBWBWBW
WBBBBBWBWB
45
BWBBBBWWBW
WBBBBWBWBW
BBWWBBWBWB
WBWBWWBWBW
BWWWBBWBWW
WBWBWBBWBB
BWBBW...

result:

ok ok (10000 test cases)

Test #23:

score: 0
Accepted
time: 135ms
memory: 3680kb

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
BWWBBWWWBB
WBBWWBWWWB
WWWBWBWWBW
WWBBBWBBWB
BBWBWBWWBB
WWWWWBWBWB
WBBBBWBBWB
BWWBWBWWBW
WBBWBWWBWB
9
BWBWBWBWWB
WBBBBBBBWB
WBBBBBBWWB
BWBBBWWBWB
BWBBWWWWBB
WBWBBWBWBB
BWWWWBW...

result:

ok ok (10000 test cases)

Test #24:

score: 0
Accepted
time: 297ms
memory: 3908kb

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
WBWWWBBWWB
BWBWBBWBBW
BBWBWWBWBB
BWBWBWBWWB
BWBBWWBBWB
BWBWBBWWBW
WBBBWBBWBB
BBBBWWWWBB
WBBWBBWWBW
WBWBWWBWBB
BWWBWBWWWB
WBWWBBWBBW
WWWBWWWBBW
BWBWBBBWWB
BWWBWBWBWW
WBBBWWBWBW
BBBWBBWWBW
BBWBWBBWWW
BWBWWBWBBB
WBWBBWBWBW
WWBBWBBWBW
WWWWBWBBBB...

result:

ok ok (1000 test cases)

Test #25:

score: 0
Accepted
time: 318ms
memory: 4144kb

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
WBWBWBWWBBBWWBWBWWBWBWWWWWBWWBWBWBWBWWWBWBWBWBBBBBBBWBWBWBBWWWBWWBWBWWWBWBWBWBWBWWBBWBBBWBWBWBWBWBWB
BWBWBWBBWBWWBWBWBBWBWBWBWBWWBWBWBWBWBWBWBWWBBWBWWWWWBWBWBWWBWBWBWWBWBWBWBWBWBWBWWBWWBWBWBWBWBWBWBWBW
BBWBWBWWWWBWBWBWBWBWBWBWWWBBWBWBWBWBWBBBWBWBWWWBWBWBWBWBBWBWBWBWBBWBWBWBWBWBWBWBBWBBWBWBWBWBWB...

result:

ok ok (1000 test cases)

Test #26:

score: 0
Accepted
time: 985ms
memory: 6872kb

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: 844ms
memory: 6872kb

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
BBBWWBWWBWBWBWBBBBBWBBBWBWWBBBBWBBBBWWBWBWWBBBBBBBWBWBBBBBWBBBWWBWWWWWBWBBBWBBWBWBWBBBWBWBWWBBBBBWBB
WWBWBWWBWBWWBWWWWWWBBWWBWBWBBBBBWWBBBWBWWBBWWWWBWBWWBBBWBWBWBBBBWBWWWBWBWWWBWWBBBBWWBWBWWWBWWBWWWBWB
WBBBWWBWBBWBWBBWBWBWBBWWBWBWWWBBBWBWWWWBWBWWBWWBWBWBWBBWBBBBWBBWBWWWBWBWBWWBBBWWWWBBBWWBWWBWB...

result:

ok ok (100 test cases)

Test #28:

score: 0
Accepted
time: 1189ms
memory: 7120kb

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
BWBWWBWBBBWBWWBWBWWWWBBBWWBBBBWBBBBWBWWBWWWWBWBBWBWWBBWBBBBBBWBBBBBWBBBBWWBWWWWWBWWBWBWWWWBBB...

result:

ok ok (100 test cases)

Test #29:

score: 0
Accepted
time: 53ms
memory: 4568kb

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
BWWWWBBBBWBBWWBWWBWBBWBBWBBBBBBBWBWWWBWWBWWBBWWWWBBBWBWBWWWBWBWBWWBWWWBBBWBBWWBWWWBBBBBBWBBBBWBWBBWB
BWWBWBBBBWWWWBBWWWBWBBWBBWWWBWBBBWBBBBBWWBWWBWBBBBBBBWWBWWWWWWBBWBBBBBBBBWBWBBWBBBWBBBBBBWBWB...

result:

ok ok (100 test cases)

Test #30:

score: 0
Accepted
time: 137ms
memory: 4596kb

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
BBBWWWBWWWBWBBWBWWWBWBBBWWBWWWBWWWBWBBWWBBBWBBWWWWBBBBWWWBWBWWBBBBWWWWBWBWBWBBBWBWBBWWBBBBWBWBWBBWWW
WBWWWBWBWWBWBWWWBBBWBWWWBWWBBWBBBWBWBBWBWWWBWWBBWWBBBWBBBWBWBBWWBWBWWWWWWBWBWBWBWWBWWBWBBWBWWWBBWBBB
BWBWWBWWBWWBWBWBWBWBWWBWWWBWWBWBBWWBWWBWBWBWBBWBWBBBWBWBWBWWWWBWBWBWBWBWBWBWBBWWWBWBBWWBWWBWW...

result:

ok ok (100 test cases)

Test #31:

score: 0
Accepted
time: 471ms
memory: 5156kb

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
BBBWBWBWBBBBWBWBBWBWBBBBWBWBBWBWWWBBBBBWBWBBWBWBBBBBBBBWBBBWBWBWBWBWBBBBBBBBBBWWBBBBBBWBWBBBWBBBWBBW
BBBBWBWBWBBBBBBWBBWBWBWBBWBWWBWBBBWBBBWBBBWWBBBWBBBBBBBBWBBBWBBBWBWBWWBWBBBWBBWBWBBBBBBWBBBBWBBWBWWB
BBBWBWBWBBWBWBBBWWBBBWBWBWWBBWBBBBWBBWBWWBWBWWBBWBBWBWBWBWBWBWBWBBBBBBWBWBBWBWBBWWBWBBBWWBBWB...

result:

ok ok (100 test cases)

Test #32:

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

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
BWBBBWBBWBWBWBWBWBBWBWBWBWBWBWBWWWBBWBWBWWBWWBWBWBWWBBWBWBWBWWBWBWBWBWWWBWBWBWWWBBBWBBWWBWBWBWWBWBWB
WBBWWBWWBWBWBWWBBWWBWBWBWBWBWWWBWBWWBWBBBBWBWWBWBWBBWWBWBWBWBBWBBBWBWBWBWBWBWBWBWWWBWWBWWBWBWBBWBWBW
BWWWBWBBWBWBBBWBWBBWBWBWBWBWBWBWBWBWBWBBBBBWBWBBWBWWBBWBWBWWBWBWBWBBBWBWWBWWBWBWBWBWBBWBBWBWB...

result:

ok ok (100 test cases)

Test #33:

score: 0
Accepted
time: 4728ms
memory: 6752kb

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
BWBBBWBWBWBWBWBWBWBWBWBWBBBWBWWWBWBWBWBWBWBWBWBWWBBBWWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWWBWWWBWBWBWB
WBWWWBWBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBBWBWBWBWBWBW
BWBWBWBWBWBWWWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWBWBW...

result:

ok ok (100 test cases)

Test #34:

score: 0
Accepted
time: 6280ms
memory: 6864kb

input:

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

output:

8988
BWBBBWBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBBBWBWBWBWBWBWBWBWBWBWBWBWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWB
BWBWBWBWBWBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB...

result:

ok ok (100 test cases)