>>106320308 (OP)
Probably you could do a prefix scan-like (? "prefix-sum"? Not sure proper name) operation. (1, 1, 0, 1, 1, 1, 0) -> (1, 2, 0, 1, 2, 3, 0). So if the question were for # of Nx1's, it'd just be the sum of that. But of course we want to consider columns. Maybe let's try a 3x3 of 1's?
1 2 3
1 2 3
1 2 3
we should get 14 somehow. Working backwards,
1x1:
1 1 1
1 1 1
1 1 1
2x2:
0 0 0
0 1 1
0 1 1
3x3:
0 0 0
0 0 0
0 0 1
merged:
1 1 1
1 2 2
1 2 3
... so maybe you'd do a scan going column-wise, and then min() w/ the prior row-wise scan? O(fucking awesome), if so. But I am a sleepy Chud and my Hitler wants me to go to bed.
>RNS0Y