0

I'm counting the number of $n \times m$ binary matrices with no zero rows or columns. Some given elements of it has been set to zero, e.g. $a_{12}=a_{23}=a_{24}=0$.

If none of the elements are set, this problem is easy. The OEIS sequence for it is A183109. And I have already seen this question, which gives a complete description. And I successfully solved this case.

However, the general problem is even harder. We must calculate the answer for all the subsets in $C$ (a fixed set of $k$ columns, the same as the meaning of the above question), because almost all of the columns are unique. Therefore the inclusion-exclusion calculation is now pretty hard to calculate.

Another try is to use another kind of inclusion-exclusion. We can choose a subset of preset of elements, and calculate the ways that they are all set to one. Once again, we should calculate for all the subsets and this is even harder.

Dynamic programming (mentioned in the first answer) seems to be slow as well.

I'd appreciate it if you could give even a small hint to make it quicker.

Dinshey
  • 555

1 Answers1

2

Here's a "dynamic programming" solution. Let $f_k(S)$ be the number of ways to choose the first $k$ rows, where $S$ is a subset of $\{1,\ldots m\}$ representing columns that are not allowed to be all empty. Thus your desired answer is $f_n(\{1,\ldots,m\})$. The "initial condition" is $f_0(\emptyset) = 1$, $f_0(S) = 0$ otherwise. The "induction step" relating $f_k$ and $f_{k+1}$ is $f_{k+1}(S) = \sum_T f_{k}(S \backslash T)$, where the sum is over all nonempty subsets $T$ of $\{1,\ldots,m\}$ that are allowed to be the the positions of $1$'s in row $k+1$ by the "given elements" constraints.

Robert Israel
  • 470,583