A Young diagram is a rectangular binary mask whose every row and every column are sorted in descending order.
It is easy to check that every rectangular binary mask can be formed by xor-ing together a finite number of Young diagrams.
This decomposition is by no means unique, but there will be a minimum number of Young diagrams required. Your task in this code golf challenge is given a number \$k\$ and an \$m\$-by-\$n\$ binary mask \$b\$ determine whether \$b\$ can be represented as xor of \$k\$ \$m\$-by-\$n\$ Young diagrams.
Example xor decompositions: These are minimal and can be used as test cases: Just take the leftmost pattern. The minimum number of Young diagrams is written just below it. If you take the pattern together with a smaller number you get a falsy test case and a truthy one otherwise. Your code needn't output the decomposition. It is typically not unique anyway.
1001 1000 1110 1111 1111 1111
0010 <- 0000 1100 1110 1111 1111
1001 0000 0000 1000 1110 1111
5
0010 1100 1110
0110 <- 1000 1110
1100 0000 1100
2
1001 1000 1100 1100 1110 1111
0100 <- 0000 1000 1100 1110 1110
1010 0000 0000 1000 1100 1110
5
1010 1000 1100 1110 1111 1111
1011 <- 0000 0000 1000 1100 1111
0010 0000 0000 0000 1100 1110
5
00111110 11000000 11110000 11110000 11111110 11111111 11111111
11101001 <- 00000000 11100000 11110000 11111000 11111110 11111111
00110111 00000000 00000000 11000000 11110000 11111000 11111111
6
10111010 10000000 11000000 11100000 11100000 11111000 11111100 11111110 11111111 11111111
10010111 <- 00000000 00000000 10000000 11100000 11110000 11111000 11111110 11111110 11111111
11100101 00000000 00000000 00000000 00000000 11100000 11111000 11111100 11111110 11111111
9
11100110 11100000 11110000 11110000 11111000 11111110 11111111 11111111
00110110 <- 00000000 11000000 11110000 11111000 11111110 11111111 11111111
00100001 00000000 00000000 00000000 11000000 11100000 11111110 11111111
7
10110011 10000000 11000000 11110000 11111000 11111000 11111100 11111111 11111111 11111111
00111100 <- 00000000 00000000 00000000 11000000 11111000 11111000 11111100 11111111 11111111
01110101 00000000 00000000 00000000 10000000 11110000 11111000 11111100 11111110 11111111
9
10110 10000 11000 11110 11111 11111
01111 00000 10000 11110 11110 11111
11101 <- 00000 00000 11100 11110 11111
10000 00000 00000 10000 11110 11110
00110 00000 00000 00000 11000 11110
5
00101 11000 11100 11110 11111 11111 11111
10010 00000 10000 11100 11110 11111 11111
10010 <- 00000 10000 11100 11110 11111 11111
10101 00000 10000 11000 11100 11110 11111
11011 00000 00000 00000 11000 11100 11111
6
0111101 1000000 1110000 1110000 1111100 1111110 1111111 1111111 1111111
1101000 0000000 1100000 1110000 1111000 1111100 1111100 1111111 1111111
1001100 <- 0000000 0000000 0000000 1000000 1110000 1111100 1111111 1111111
0000001 0000000 0000000 0000000 0000000 1110000 1110000 1111110 1111111
0110010 0000000 0000000 0000000 0000000 1000000 1110000 1111100 1111110
8
0001010 1000000 1000000 1110000 1111000 1111100 1111110 1111111 1111111
1000011 0000000 1000000 1100000 1100000 1111000 1111000 1111100 1111111
0100011 <- 0000000 0000000 1000000 1100000 1111000 1111000 1111100 1111111
1011010 0000000 0000000 0000000 1000000 1100000 1111000 1111100 1111110
1111110 0000000 0000000 0000000 0000000 0000000 0000000 0000000 1111110
8
011000101 100000000 111000000 111111000 111111100 111111110 111111110 111111110 111111111
000100001 000000000 000000000 111000000 111100000 111111110 111111110 111111110 111111111
111100111 <- 000000000 000000000 000000000 111100000 111111000 111111110 111111110 111111111
111100001 000000000 000000000 000000000 000000000 000000000 111100000 111111110 111111111
110000000 000000000 000000000 000000000 000000000 000000000 000000000 000000000 110000000
8
001100011 110000000 111100000 111110000 111110000 111111100 111111110 111111110 111111111 111111111 111111111
000110101 110000000 110000000 111000000 111110000 111111000 111111100 111111110 111111111 111111111 111111111
011011100 <- 100000000 110000000 110000000 111000000 111100000 111111000 111111000 111111100 111111111 111111111
100000001 000000000 100000000 110000000 110000000 111100000 111100000 111111000 111111000 111111110 111111111
110101001 000000000 000000000 000000000 110000000 111000000 111100000 111110000 111111000 111111110 111111111
10
Standard rules apply.