QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#101647#6377. LaLa and Magic Stonewillow#WA 4ms4788kbC++145.6kb2023-04-30 16:48:532023-04-30 16:48:57

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-30 16:48:57]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4788kb
  • [2023-04-30 16:48:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005, mod = 998244353;
const int step[4][7][2] =  {{{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 2}, {2, 0}, {2, 2}}, 
							{{0, 0}, {2, 1}, {0, 2}, {1, 0}, {1, 2}, {2, 0}, {2, 2}}, 
							{{0, 0}, {0, 1}, {0, 2}, {2, 1}, {1, 2}, {2, 0}, {2, 2}}, 
							{{0, 0}, {0, 1}, {0, 2}, {1, 0}, {2, 1}, {2, 0}, {2, 2}}};
int Add(int x, int y) {
	return (x += y) >= mod ? x - mod : x;
}
int Mul(int x, int y) {
	return 1ll * x * y % mod;
}
int n, m;
char s[maxn][maxn];
int Canput(int x, int y, int k) {
	if(x < 1 || y < 1)
		return 0;
	if(x + 2 > n || y + 2 > m)
		return 0;
	if(s[x + 1][y + 1] == '0')
		return 0;
	for(int i = 0; i < 7; ++ i) {
		int nx = x + step[k][i][0], ny = y + step[k][i][1];
		if(s[nx][ny] == '1')
			return 0;
	}
	return 1;
}
void Put(int x, int y, int k, char c) {
	for(int i = 0; i < 7; ++ i) {
		int nx = x + step[k][i][0], ny = y + step[k][i][1];
		s[nx][ny] = c;
	}
}
int Solve(int x, int y, int ans) {
// cerr << x << " " << y << " " << ans << " " << s[x][y] << endl;
// for(int i = 1; i <= n; ++ i, cerr << endl)
// 	for(int j = 1; j <= m; ++ j)
// 		cerr << s[i][j];
	if(!ans)
		return 0;
	if(x == n + 1)
		return ans;
	if(s[x][y] == '1')
		return Solve(x + (y == m), y == m ? 1 : y + 1, ans);
	if(x >= n - 1 || y >= m - 1)
		return 0;
	if(s[x + 2][y] == '1' || s[x][y + 2] == '1' || s[x + 2][y + 2] == '1')
		return 0;
	long long res = 0;
	if(s[x + 1][y + 1] == '0') {
		int f = 1;
		for(int i = 0; i < 3 && f; ++ i)
			for(int j = 0; j < 3 && f; ++ j)
				if(s[x + i][y + j] == '1')
					f = 0; // , cerr << x + i << " " << y + j << endl;
		if(!f)
			return 0;
		f = 0;
// cerr << s[x + 1][y - 1] << " " << s[x + 2][y - 1] << " " << s[x + 3][y - 1] << " " << s[x + 3][y] << " " << s[x + 3][y + 1] << endl;
		if(y > 1 && x + 3 <= n && s[x + 1][y - 1] == '0' && s[x + 2][y - 1] == '0' && s[x + 3][y - 1] == '0' && s[x + 3][y] == '0' && s[x + 3][y + 1] == '0') {
			f |= 1;
		}
		if(y + 3 <= m && x + 3 <= n && s[x + 1][y + 3] == '0' && s[x + 2][y + 3] == '0' && s[x + 3][y + 3] == '0' && s[x + 3][y + 2] == '0' && s[x + 3][y + 1] == '0') {
			f |= 2;
		}
		if(f == 1) {
			Put(x, y, 2, '1');
			Put(x + 1, y - 1, 3, '1');
			res = Solve(x + (y == m), y == m ? 1 : y + 1, Add(ans, ans));
			Put(x, y, 2, '0');
			Put(x + 1, y - 1, 3, '0');
		}
		else if(f == 2) {
			Put(x, y, 3, '1');
			Put(x + 1, y + 1, 2, '1');
			res += Solve(x + (y == m), y == m ? 1 : y + 1, Add(ans, ans));
			Put(x, y, 3, '0');
			Put(x + 1, y + 1, 2, '0');
		}
		else if(f == 3) {
			if(Canput(x + 1, y - 3, 0) && Canput(x + 3, y - 2, 1)) {
				Put(x, y, 3, '1');
				Put(x + 1, y + 1, 2, '1');
				Put(x + 1, y - 3, 0, '1');
				Put(x + 3, y - 2, 1, '1');
				res += Solve(x + (y == m), y == m ? 1 : y + 1, Add(ans, ans));
				Put(x, y, 3, '0');
				Put(x + 1, y + 1, 2, '0');
				Put(x + 1, y - 3, 0, '0');
				Put(x + 3, y - 2, 1, '0');
			}
			else {
				Put(x, y, 2, '1');
				Put(x + 1, y - 1, 3, '1');
				res = Solve(x + (y == m), y == m ? 1 : y + 1, Add(ans, ans));
				Put(x, y, 2, '0');
				Put(x + 1, y - 1, 3, '0');
			}
		}
		return res % mod;
	}
	else {
		int k = -1;
		if(s[x][y + 1] == '1') {
			if(k == -1)
				k = 1;
			else
				k = -2;
		}
		if(s[x + 2][y + 1] == '1') {
			if(k == -1)
				k = 0;
			else
				k = -2;
		}
		if(s[x + 1][y] == '1') {
			if(k == -1)
				k = 2;
			else
				k = -2;
		}
		if(s[x + 1][y + 2] == '1') {
			if(k == -1)
				k = 3;
			else
				k = -2;
		}
		if(k == -2)
			return 0;
		if(k != -1) {
			Put(x, y, k, '1');
			res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
			Put(x, y, k, '0');
		}
		else { // 8 empty.
			for(k = 0; k < 4; ++ k) {
				if(k == 1)
					continue;
				if(k == 3 && Canput(x + 1, y + 2, 2)) {
					Put(x, y, k, '1');
					res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
					Put(x, y, k, '0');
				}
				if(k == 0) {
					int f = 0;
					if(Canput(x + 2, y + 1, 1))
						f |= 1;
					if(Canput(x + 2, y - 1, 1))
						f |= 2;
					if(f == 1) {
						Put(x, y, k, '1');
						Put(x + 2, y + 1, 1, '1');
						res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
						Put(x, y, k, '0');
						Put(x + 2, y + 1, 1, '0');
					}
					else if(f == 2) {
						Put(x, y, k, '1');
						Put(x + 2, y - 1, 1, '1');
						res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
						Put(x, y, k, '0');
						Put(x + 2, y - 1, 1, '0');
					}
					else {
						if(y > 1 && s[x + 1][y - 1] == '0') {
							Put(x, y, k, '1');
							Put(x + 2, y + 1, 1, '1');
							res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
							Put(x, y, k, '0');
							Put(x + 2, y + 1, 1, '0');
						}
						else if(Canput(x + 2, y - 3, 0) && Canput(x + 4, y - 2, 0)) {
							Put(x, y, k, '1');
							Put(x + 2, y + 1, 1, '1');
							Put(x + 2, y - 3, 0, '1');
							Put(x + 4, y - 2, 1, '1');
							res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
							Put(x, y, k, '0');
							Put(x + 2, y + 1, 1, '0');
							Put(x + 2, y - 3, 0, '0');
							Put(x + 4, y - 2, 1, '0');
						}
						else {
							Put(x, y, k, '1');
							Put(x + 2, y - 1, 1, '1');
							res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
							Put(x, y, k, '0');
							Put(x + 2, y - 1, 1, '0');
						}
					}
				}
				if(k == 2 && Canput(x + 1, y - 2, 3)) {
					Put(x, y, k, '1');
					res += Solve(x + (y == m), y == m ? 1 : y + 1, ans);
					Put(x, y, k, '0');
				}
			}
		}
		return res % mod;
	}
	return res % mod;
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i)
		scanf("%s", s[i] + 1);
	printf("%d\n", Solve(1, 1, 1) % mod);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3572kb

input:

4 4
0001
0000
0000
1000

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

5 4
0001
0101
0000
1010
1000

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

3 3
111
111
111

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

3 4
1111
1111
1111

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

3 1000
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

4 3
111
111
111
111

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

4 4
1111
1111
1111
1111

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

4 1000
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 2ms
memory: 4772kb

input:

1000 3
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
111
1...

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 2ms
memory: 4788kb

input:

1000 4
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
111...

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 4ms
memory: 4544kb

input:

1000 1000
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Test #12:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

3 3
000
010
010

output:

1

result:

ok 1 number(s): "1"

Test #13:

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

input:

3 3
000
011
000

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

3 3
010
010
000

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

3 3
000
110
000

output:

1

result:

ok 1 number(s): "1"

Test #16:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

4 4
1000
0000
0000
0001

output:

2

result:

ok 1 number(s): "2"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

4 4
0001
0000
0000
1000

output:

2

result:

ok 1 number(s): "2"

Test #18:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

3 3
010
101
101

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

3 4
1011
0100
1111

output:

0

result:

ok 1 number(s): "0"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

3 1000
10011010111111111111000101011100101000000011110011011000110000100110110110111110000111011001010010011100001111111011111111110010110100011101011100100100001110010011111011111101001110011010010110110011001100101010001101100111101001001001101000101011101000100100001111100000010010111101101001000...

output:

0

result:

ok 1 number(s): "0"

Test #21:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

4 3
010
101
110
000

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

4 4
0110
1010
1101
1110

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 2ms
memory: 3512kb

input:

4 1000
01001110100001111110010111111001110111001110100100101101001110110111001111101100111110001110100000010101110001100001011000100111001111101110100001010101100011101110000010110101101100001000111101111000110100110000110111111101111101000011100001001110011000110110001110110011010111101101101001000...

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 0ms
memory: 4772kb

input:

1000 3
011
011
101
011
101
011
100
101
110
010
101
010
010
100
100
000
010
101
011
110
101
110
011
101
100
110
011
011
101
101
111
001
101
100
110
110
101
011
010
100
100
110
110
100
110
101
111
011
101
001
101
101
001
110
110
010
101
110
010
100
010
110
010
110
111
101
100
001
000
001
110
001
111
0...

output:

0

result:

ok 1 number(s): "0"

Test #25:

score: 0
Accepted
time: 1ms
memory: 4540kb

input:

1000 4
1000
0000
1010
0100
0101
0011
1101
0000
1001
0001
1111
0100
1101
0111
1110
1001
0100
0011
0011
1000
1001
1100
0110
0100
1100
0111
0010
0110
1111
1101
1001
0010
1110
1100
1000
0111
0010
0100
1001
0101
1111
0000
0110
0011
0110
1000
0110
1111
0000
0000
1011
1000
0000
0101
1001
0001
0100
0110
011...

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 0ms
memory: 4600kb

input:

1000 1000
00111010100111001111101110110011111101010111001010011001011000100100110011000111000000100010011101100011001001101110100001000101111100100110101010101011000111010101000110000110001100110011111000011100100001001110110000110010000111010110100001010100100101000011110001010111011011101111001011...

output:

0

result:

ok 1 number(s): "0"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

58 17
10001101010001111
10111101010000111
10001100010000000
00011000111000010
01110000111111010
00010000111111111
11110001111110001
11100010001100001
11100000000100001
11100000000100011
11110001000111000
00010001000110000
00000101000010000
00000101000010001
10001111100011111
11111111000111000
111000...

output:

0

result:

ok 1 number(s): "0"

Test #28:

score: 0
Accepted
time: 2ms
memory: 3820kb

input:

16 13
1111111111111
1111111111111
1000110001111
1000100000001
1000000000000
1100000010000
1111111111000
1111111111111
1110001111111
1110000111000
1110000110000
1111000110000
1100010000001
1000010000111
1000010000111
1000111000111

output:

0

result:

ok 1 number(s): "0"

Test #29:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

9 78
000111111111111111000111111111100011100010000001111111111111111111111111110001
010100011111111111000011111111100001000000000000111111110001111000110001110000
110100001111110001000011100011100001000000000000010111110000110000100001110000
1000000011111100001000111000011100010001000110000100001100...

output:

0

result:

ok 1 number(s): "0"

Test #30:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

18 55
1111110001111111111111000111111111111111111000111111111
1111110000100010001000000011100011000111110000111111111
1110000000111010000010000011100001000000010000111111111
1100001000100010000010100011100001000000000001100011111
1100001110001111000111111111110001100000001111100000101
11000111100001...

output:

0

result:

ok 1 number(s): "0"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

124 5
10001
10000
10000
11000
00011
00001
00001
10001
00011
00001
00001
10001
11111
00011
01011
01011
11111
11111
10001
00001
00001
00011
10001
00001
00001
00011
00011
01011
01011
11111
11111
11111
11000
10000
10000
10001
11111
11111
11111
11111
11000
10000
10000
10001
10001
10000
10000
11000
11000
...

output:

1048576

result:

ok 1 number(s): "1048576"

Test #32:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

117 6
110001
111101
110001
111000
110000
110000
110001
111111
100011
100001
100001
110001
111111
111111
111111
111000
110000
110000
110001
100011
000011
000011
000111
000111
000011
000011
100011
000111
000011
000011
100011
111111
000101
010111
010000
110000
110000
110001
111111
111111
111111
111111
...

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

25 19
1111111111111111111
0001111111111000111
1101111111111110111
0001110001111000111
1111100001111100011
1111100000001100001
1111100010101100001
1111111110101110001
0001111111111111000
1101100011111110000
0001000011000110000
1111000010000110001
1000000110000000111
0000111110001000011
00001111111110...

output:

8192

result:

ok 1 number(s): "8192"

Test #34:

score: 0
Accepted
time: 2ms
memory: 3896kb

input:

83 5
00011
00001
00001
10001
11111
10001
10000
10000
11000
00011
00001
00001
10001
00011
01111
00011
10001
00001
00001
00011
10001
10101
10101
11111
11111
10001
00001
00001
00011
10001
00001
00001
00011
11111
10001
00001
00001
00011
11111
10001
10000
10000
11000
00011
00001
00001
10001
11111
11111
1...

output:

32768

result:

ok 1 number(s): "32768"

Test #35:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

30 28
1111111111111111111110001111
1111000111111111000111101000
1110000000111110000110000000
1110000000010000000000110000
1110001000000000000000110001
1000111100000001110000000111
1010111111100011110001000011
1010111111111111111111000011
0001111111110001111111100011
0000110001100001000100011111
0000...

output:

33554432

result:

ok 1 number(s): "33554432"

Test #36:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

64 8
11111111
11111111
00011111
00001111
00001000
10000000
11110000
11110001
11111111
11100011
11000011
11000011
11000111
11111111
11000111
11000011
11000011
11100011
11111111
11100011
11000011
11000011
11000111
11111111
11100011
11100001
00000001
00000001
00001111
10001111
11100011
11000011
1100001...

output:

0

result:

ok 1 number(s): "0"

Test #37:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

5 141
111111000111111111000111111111111111111011111000111111111111111110100001111100011100010001110001100011100011110001100010001100010001111000111
100010000100011110000110001000111100001010001000000000011111110000100000000100001000010101100001100001100001100001100000000100000000110000111
1000000000...

output:

0

result:

ok 1 number(s): "0"

Test #38:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

10 73
1111111111111111100011111111111111111110001111111000011111111111101000011
1111100010001111000011111110001110001110000110001000011111000111101000001
1111000010111111000011111110000100001110000100001000000011000011100000001
111100001000111100011111000000010000111100010000100010000100000001111000...

output:

0

result:

ok 1 number(s): "0"

Test #39:

score: 0
Accepted
time: 2ms
memory: 3840kb

input:

27 29
11000111111100011111111111111
11000011111000011100011111111
11000000011000011100001110001
11100001011000111100001110101
11111101011000111110001110101
11111111111000011111111110001
11100011111000011100011100001
11100001101000011100001100001
11100001101010001100001100011
111100011000000011100011...

output:

67108864

result:

ok 1 number(s): "67108864"

Test #40:

score: 0
Accepted
time: 2ms
memory: 3572kb

input:

6 85
1111111111100011100011111111111111100011100011111100011111000111000111111111111111000
1000111000100001111011111111111000000011000011111101011110000110000111111110001111110
1000010000100001100010001100010000000011000011000101000010000110000111000100000001000
1000010000110001000110000101010000000...

output:

0

result:

ok 1 number(s): "0"

Test #41:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

16 21
100010001111111111000
101000001111000111010
101001001111000011010
111100000011000011111
100011100001100000011
100001100001111000011
100001110001111000011
110001111111111000000
111111111111111110000
111111111111000110000
100011000111010010001
100000000111000011111
100000000100000011000
11000000...

output:

0

result:

ok 1 number(s): "0"

Test #42:

score: 0
Accepted
time: 2ms
memory: 3824kb

input:

14 69
111111111110001111111111100010001111111111000100011010101010101000000
111111111110000111100011000010101111111111000000001010101010101110110
111111111110000111100001000010100001100011000000001000100010001000000
111000111111000000100001000111110000100001100010001111000111100011111
11100001111111...

output:

0

result:

ok 1 number(s): "0"

Test #43:

score: 0
Accepted
time: 2ms
memory: 3572kb

input:

7 22
1111111111111000000111
1111000100010000010111
0000000000010000010111
0100000000010001000111
0100001000110101000011
1111111111110101000011
1111111111110001110011

output:

0

result:

ok 1 number(s): "0"

Test #44:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

55 18
111111111111111111
111111111111101011
000111111111101011
000011100011100011
000011100001100011
100011100001100001
110001110001100001
110000111111110001
110000111000110001
111000111000010000
100011111000010000
000000011100011000
000000001111000111
000100001110000111
111110001110000111
111110001...

output:

150994942

result:

ok 1 number(s): "150994942"

Test #45:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

13 76
1110001111111111000111100011111111111111111111111111111111111111110001111111
1110000111110001000011101011111110001100010001111111111000111111110000111111
1110000111100001000011101011100010000000010101100010001000011110000000111111
111100010000000110001111111111101000000001010100000000100001110...

output:

0

result:

ok 1 number(s): "0"

Test #46:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

33 10
1111111111
1111111111
0001111111
0000010111
0000010000
1000000011
1111111000
1111110001
1111110000
1000110000
0000111000
0000100011
0001000011
1111000011
1111000111
0001111111
0000100011
0000100001
1000100001
1111110001
1111010111
1111010111
0001000111
0000110001
0000100001
1000100001
11000000...

output:

1024

result:

ok 1 number(s): "1024"

Test #47:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

22 44
10000001111111111111111111111111110001110001
00001101111111100000011100010001100001100001
00000000000001000011011100000000100001100001
00011100000000000000011100000000100000000011
11111100000000000111110000001000111000011111
11111100011000111111100001010111111000010001
111000111111111111000000...

output:

0

result:

ok 1 number(s): "0"

Test #48:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

29 32
11111111000111111110001111000111
11110000000111111100001111000011
10000100000110001100000001000011
00000100001110000100010000100011
00001111111110000111110000111111
00011100000011000111111000111111
11111101001011111100011000100011
11000101001000011100110000000011
110000111110000111000100000000...

output:

0

result:

ok 1 number(s): "0"

Test #49:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

41 24
111111000111111111000111
111111000011111111000011
111111000011000111000011
111100000011000011100011
111000011111000011111111
111000011000100000010001
111000110000111000010111
000111110000111000010001
010111110000001000111111
010111100010111111111111
111100001010001111100011
1110000010111110001...

output:

150994942

result:

ok 1 number(s): "150994942"

Test #50:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

29 14
11111111111000
10001111111010
10111111000010
10000001000011
00000001000011
11000001100011
00000000011111
00011000001111
00001000010001
00001000110000
10001010110000
10001010111000
00001000111101
00000001111000
00000001110010
11100001110000
11100011110001
11000100011111
10000100001111
100001000...

output:

0

result:

ok 1 number(s): "0"

Test #51:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

30 16
1111100011111111
1111100001100011
1111100001101011
1111110001101011
0001111111100011
0000100000000001
0000000001100001
1000000000010011
1111000111111111
1111111111111111
1111000100011111
0000000100000001
0110000100001101
0000000000000001
1111110000111000
0001110000111110
0000111000111000
00001...

output:

0

result:

ok 1 number(s): "0"

Test #52:

score: 0
Accepted
time: 2ms
memory: 3572kb

input:

12 52
1110001111111000111111111100011111000111111111111111
1110110001110000010110001000011111000011111111000011
1110001101110000010100001000011111000010001111000011
1100010000000001000100001000111111100000001111000011
1000011100001111111101011111000111100000001111000111
10000111000011111100011111110...

output:

0

result:

ok 1 number(s): "0"

Test #53:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

42 13
1111111111111
1111100010001
1000100000111
0000100000001
0000110001111
0001110001111
1111110000111
1110000000111
1110000000111
1110000111111
1111000110000
1110000110000
1100001110000
1100001110001
1100000000011
1111000001011
1111000001011
1000000111111
1010100011111
1010101111111
1100000000011
...

output:

0

result:

ok 1 number(s): "0"

Test #54:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

10 82
1000111110000001111111110001111111111111111110001000111101011111111111000111100011
1000011110100000111111110111111111111111000110111000011101011000100010000111000011
1000011110100000111111110001111111000111000010001000000000011000001110000111000011
110001110001100011110001111111111000011100001...

output:

2097152

result:

ok 1 number(s): "2097152"

Test #55:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

30 32
11000111111000111111110001000111
11010000110000111111100001000011
11010000010000100011100001000011
11111000010001100001100001000011
11111100011111100001111101000011
11111111000111110001111100000001
11111111000010001100111111100001
00011111000010000000011111110001
110111111000100000000110001000...

output:

0

result:

ok 1 number(s): "0"

Test #56:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

5 35
11111111000100011111111111111000111
11000111000000001100011000010000011
11000011000000001100000000010000011
11000011100010001100000000000100011
11100011111111111110000001111111111

output:

64

result:

ok 1 number(s): "64"

Test #57:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

44 16
1111111100011111
1111111000011111
1100011000011111
1000011000110001
1000011000110000
1000111011110000
1010111000111000
1010111000010111
1000110000010111
1111110000000000
0001110001110000
0000111111110000
0000111000110001
1000110000111111
0001110000101011
0101110001101011
0101111111100011
11111...

output:

4194304

result:

ok 1 number(s): "4194304"

Test #58:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

100 10
1111111111
1010100011
1010100101
1000100001
1110000001
0000000111
1100000010
0001000010
1111000000
1111010000
1000010010
1000011010
1000010101
1100000101
0001110001
0000111010
0000111010
1000111000
1111111111
1110001111
1100001111
1100001111
1100011111
1111100011
1111000011
1111000011
1111000...

output:

0

result:

ok 1 number(s): "0"

Test #59:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

71 8
11111111
11111111
00000011
01100001
00000001
11110001
11000111
11000011
11000011
11100011
11111111
00011111
11011111
00000011
11000011
11000011
11000000
11110000
11110000
11110001
00011111
00001000
00000000
10000000
10000001
10000111
10000111
11000111
11111111
11111111
11110001
11110000
1000000...

output:

131072

result:

ok 1 number(s): "131072"

Test #60:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

9 11
11110000111
11110000111
11110000111
10010001111
01001100011
00001100001
10001100001
11111110001
11111111111

output:

0

result:

ok 1 number(s): "0"

Test #61:

score: 0
Accepted
time: 2ms
memory: 3844kb

input:

33 24
100011111111110001110001
000011000101000001110000
000010000101000001110000
000110000100000011111000
111110001111100000011111
110001100011101111011000
110000101111100000010000
110000100011111110000000
111000111100011100000001
111111111000011100001000
111111111000011100011110
1111000110001111111...

output:

8388608

result:

ok 1 number(s): "8388608"

Test #62:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

8 123
100011100011111010110001111111111110001111100011000111111111111111010111110001111111100011111010111111111111100011110001111
100001100001111010111101100011100000000001100001011111111111111111010100010000110001000000011010100001011000100001111101111
1000011000011110001100010000111110000000001000...

output:

536870912

result:

ok 1 number(s): "536870912"

Test #63:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

14 36
111111111000110001111111111000100011
111111111000000001111100010000100001
111110001000000000001000010000100001
110000000100000010000000010001110001
100000000000111110000000111111111111
100001000000010111000111111100011111
100011111000010001111111000100001111
11111111110001011111111000010000000...

output:

0

result:

ok 1 number(s): "0"

Test #64:

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

input:

9 110
11111111111111111111111111111110001000100011111111111111111010111111111110001111111100011111111111111100010001
10100001111111000100010001110000000000011011110001000111111010000111111110000110001000011111111111100000000101
101000001100011101000001111000000000000000000101100001111110000000110001...

output:

0

result:

ok 1 number(s): "0"

Test #65:

score: 0
Accepted
time: 2ms
memory: 3812kb

input:

13 66
100011100011111111111100000011111111111111111110001111111100011111
100001000011111111111000000001111100000011100010101110001000011111
100001000010000001111000000001111101100001101010101100001000000011
110001000100000000000000110001111100000001101011100000001000101011
11111111110000000000000001...

output:

0

result:

ok 1 number(s): "0"

Test #66:

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

input:

23 43
1111111111111111111111111100011101011111111
1111110001111111111111000101011101011111111
1111100001000111111111000001011100011111111
1111100000000111111111000011111110001110001
1111100010000111000111100011111100000000000
1111111110001111000011111111000100000110000
110001111111111100001111111000...

output:

0

result:

ok 1 number(s): "0"

Test #67:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

50 20
11100010001111100011
11000000001111100001
11000000001000100001
11000100010000110001
00011111110000111111
11011111110001010111
00000011100011010111
11100001100001000111
11100001100001111111
11110001110001000111
11110101111110000111
10000101100010000111
00000001000010000001
00001111000011100001
...

output:

419430366

result:

ok 1 number(s): "419430366"

Test #68:

score: 0
Accepted
time: 2ms
memory: 3764kb

input:

15 26
11100010001111110001100011
11000011101111110000100001
11000010000001110000100001
11000100010000111000110001
11111101110000010111111111
11111100011000010111111111
11111111111111000110001111
00011100000011111100001111
00001000000001111100001111
00001100000001000100011111
100010001100010101111110...

output:

0

result:

ok 1 number(s): "0"

Test #69:

score: 0
Accepted
time: 2ms
memory: 3820kb

input:

13 76
1000110001111111111111111111111111111111111000111110001111100011110001111111
1000000001100010001111111110001100011111010000000000001000101011100001000111
1000000001000010111111111110000101010001010000011000000000101011100001000011
110000001100001000111000111000010100000100010000000001000011110...

output:

0

result:

ok 1 number(s): "0"

Test #70:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

19 48
000111111111100011111111111000111111111111110001
110111111111000011100011111000011111111111100001
000100011111000011111011111000011000100001000001
111000001111000111100011000100011000001001000011
111000011111111111000110000111111000001000000011
111000111000111111000010000111111100011111000011
...

output:

0

result:

ok 1 number(s): "0"

Test #71:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

21 24
111111100011111111111111
100011000011111000111000
100001000011110000110000
100001000111110000110000
110001111111110001110001
111111110000001111111111
111111111100000100011111
111000110000000101111111
111000011000000100011111
111000010000111110001111
111100010000010100000001
1000111100010101000...

output:

32768

result:

ok 1 number(s): "32768"

Test #72:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

54 16
1111111110001111
1111100010000000
0001100000000110
0000100001000000
0000110001111111
1000111100011111
1111100000001111
0001000000001111
0000000010001111
0000000111111000
1000111111110000
1111111000110000
1111110000110001
1111110000111111
1111110001100011
0001111111000011
0101111111000011
01011...

output:

33554432

result:

ok 1 number(s): "33554432"

Test #73:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

14 70
0001111111111111111111111111111111111111111111111111111111111100011111
0110001111000111111100011000110001111111111111111100011110001100001111
0000000111000011000000010000110111000111111111111000011100001100001000
0100000111000010000000010000110000000111111111111000011100001110001110
0101000000...

output:

0

result:

ok 1 number(s): "0"

Test #74:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

26 11
11000111111
11000011111
11000000011
11100011011
00011100011
00001110001
00001111101
10001110001
11111111111
11111100011
11111000011
11111000011
10001000111
00001111111
00001111111
00011100011
11111100001
11111100001
01110000001
11100001111
11100001111
00000011111
00001110001
00001100001
100011...

output:

0

result:

ok 1 number(s): "0"

Test #75:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

17 48
111111111111111111111100001011000111111111111111
111111111111000111111000001011010111111000110001
111111111000000000011000000011010000110000100001
100011111011000000001000000111110000110000100001
000010001000100000001011000000010000110001100011
000010000110100000001111000001010001111111110101
...

output:

0

result:

ok 1 number(s): "0"

Test #76:

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

input:

20 18
111111000111111111
111110000100011111
111110000000011000
110000001000010000
110000111000110000
110000111111110001
000000111111100011
110110001111000011
000100001111000011
111100000001000111
000100000001111111
000011100001111111
000011100011100011
100011111111000011
110000001111000011
100000111...

output:

2048

result:

ok 1 number(s): "2048"

Test #77:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

13 71
11111110001111111111010111111111110001111111110001111111111111110001111
11111111101111110001010110001010110111111111100001111111110001100001111
11111110001111100001000100001010110001111000100001100000010000100001111
11100011111111100001111100001000111000110000100011000000000000100011111
110000...

output:

0

result:

ok 1 number(s): "0"

Test #78:

score: 0
Accepted
time: 2ms
memory: 3676kb

input:

105 6
111111
111111
111111
111000
110000
110000
110001
111111
111111
000000
011011
000000
111000
110000
110000
110001
111111
111000
110000
110000
110001
111111
111111
111010
111010
111000
111111
111111
111111
000111
000011
000011
100011
111111
111111
110001
100001
100000
100011
100011
000011
000011
...

output:

0

result:

ok 1 number(s): "0"

Test #79:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

21 39
100011111111111110001111111111111110001
101010001111111100001111111100011110000
101000001110001100001111111000011110000
111100001100001100010001111000000011000
111100011100001111110000111000000011111
111111111100011111110000100011000011111
111111111111110001111000100001000111000
11000111111110...

output:

0

result:

ok 1 number(s): "0"

Test #80:

score: 0
Accepted
time: 2ms
memory: 3848kb

input:

32 23
11111111110001000111111
11000110000000000011111
11000010110000000011111
11000010001000100000011
11100011110001111100001
11111111111101000100001
11111111110001000010001
11111111111000000011111
10001100010000100011111
10000100000000100011000
10000100000001111010000
11000110001111100010000
111111...

output:

16777216

result:

ok 1 number(s): "16777216"

Test #81:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

33 20
11110000001111111111
11110100000110001111
10000100000110111111
10000111000110001000
10000111111111110000
11000111111100010000
11111000111000010001
11111000011000011111
11111000011000111111
00011100011000100011
00001111110000100001
00001111110000100001
10001000110001110001
11111000011111100011
...

output:

262144

result:

ok 1 number(s): "262144"

Test #82:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

6 54
111111111111111111111111111000111111111110001111110001
111111111011111111111111111010000111110000000100000001
100011110001100000011110001010000000010110000111000001
100000100000000000001100001111000000000001000100000011
100000100000000000001100001111100000001111111111111111
11000000100000011000...

output:

0

result:

ok 1 number(s): "0"

Test #83:

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

input:

22 14
11111100011111
11111100000001
11111100000000
11100010000000
11100000001000
11100000000000
10000000000011
00001111000000
00001110001111
00011100001111
10001100000001
11101100011101
10000001110001
11100001111111
11100001111111
11100011110001
11111111110000
11100011110000
11000000011000
110000011...

output:

512

result:

ok 1 number(s): "512"

Test #84:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

5 22
0001111111100011111111
0000000111000011110001
0000000011000011100001
1000000011000111100001
1111100011111111100011

output:

16

result:

ok 1 number(s): "16"

Test #85:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

38 14
11111111000111
11111111000011
11110001000011
11100001100011
11100001111111
11100011110001
11111111110000
10001111110000
10110000001000
10001100000111
11110000000111
10101111000111
10101111111111
10000001111111
11110000100011
11110000000011
11111000000011
11111111000111
11111100011111
110001110...

output:

0

result:

ok 1 number(s): "0"

Test #86:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

91 9
100011000
000011010
000011010
000111000
000110000
110110000
000110001
111111111
111110001
111110000
100010000
000011000
000011111
000111000
101010000
101010000
100010001
111000111
110000111
110000111
110001111
100011010
000011010
000011000
000111111
111100011
111000011
000000011
010000111
01011...

output:

8388608

result:

ok 1 number(s): "8388608"

Test #87:

score: 0
Accepted
time: 2ms
memory: 3776kb

input:

19 30
111111111100011110001111111111
111110001100000001101111111111
000100001100000110001100011111
010100001110000001100011010001
010100011111110001000000000001
110001111111100001000011100001
100001100011100001000111100011
100001000011100011000111111111
100011000011111110000111110001
111111000111000...

output:

65536

result:

ok 1 number(s): "65536"

Test #88:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

11 14
11111111111111
00011111111111
00001111000111
00000001000011
10000000000011
11110000100011
11111000111110
11111000100011
00011000000001
01111000000001
00011100010001

output:

0

result:

ok 1 number(s): "0"

Test #89:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

20 8
11111111
11111111
11110001
11100001
00000001
01000011
00000001
10100000
10000000
10001000
10000111
10000111
11000111
11111111
01011111
01010001
00010000
11110000
11111000
11111111

output:

16

result:

ok 1 number(s): "16"

Test #90:

score: 0
Accepted
time: 2ms
memory: 3816kb

input:

7 41
11111000111111111110001111111111110001111
11111000010001111100000001111111110000111
11000000010000111100000000110001110000111
11000000010000111100010000110000000000111
11000011111000000111111000110000000011111
11100011111111110111111111111000000011111
11111111111111000111101111111111100011111

output:

0

result:

ok 1 number(s): "0"

Test #91:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

62 15
111111111111011
111111110001111
111111100001111
100011100001111
000011100010001
000011000100001
000111110100001
111000000100011
110000111111111
110000111111111
110001111000111
100011111000011
111011111000011
100011111100011
111100011111111
111000011111111
111000011111010
111000110001010
111111...

output:

0

result:

ok 1 number(s): "0"

Test #92:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

33 7
1000000
0000011
0000000
0001111
1111111
1111111
1100011
1000011
1000011
1000111
1111111
1100011
1100001
1100001
1110001
1111111
1000111
1000011
1000011
1100011
1100011
1000011
1000011
1000111
1100011
1100001
1100001
0000001
0100001
0100000
1110000
1111000
1111111

output:

128

result:

ok 1 number(s): "128"

Test #93:

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

input:

10 30
111111111111111111111100011111
110001100010001111111100001111
100001000010000111111100000001
100001000010000110001110000000
100011000000000100001111110000
111110001110111100001000111000
110000000000000100011000010001
110110000110000110101000010000
110001000110000110101100010000
111111111110001...

output:

1024

result:

ok 1 number(s): "1024"

Test #94:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

16 62
11000000111100011111111111000111111111111111000010111110001111
10000010111100000101100010000110001100010000000010000111101111
10000010111100000101000010000111101100011100000000000010001111
10001111111110000001000010000000001000010000001111000011000111
111111111000111111110001111000011110001111...

output:

0

result:

ok 1 number(s): "0"

Test #95:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

66 15
111111111111111
000111111111111
000011110001111
000010000000000
100010110000011
111110001000000
111100011110001
111100001110101
111100001110101
111110001111111
111111000111111
111110000111111
111110000111111
111110001111000
000111111110000
000010001110000
000010000110001
100010000000111
111111...

output:

0

result:

ok 1 number(s): "0"

Test #96:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

23 31
1111111111111111111111111110001
1111111111110001110001111110000
1111111111110111100001111110000
1111111000110001100001000111000
0001110000110001100011000011111
0000110000100001100011000011111
0000110001100001100001100000011
1000111111100011100001111100001
1111000111111000110001111100001
111100...

output:

0

result:

ok 1 number(s): "0"

Test #97:

score: -100
Wrong Answer
time: 1ms
memory: 3524kb

input:

10 100
1111111100011111111111000110001111111111111111111000100011111111111111110101111111000111111111111111
1111111000011111100011000010000111111111111111111011000011111111111100010100001110000111111100011111
1110001000011000100001000010000100011111111110001000000011000111100000000000000110000000111...

output:

536870912

result:

wrong answer 1st numbers differ - expected: '0', found: '536870912'