Skip to main content

Chess Picking Problem

· 3 min read
Xinyu Ma
Research Scientist @ Meta

Rephrase the chess picking problem in a more formal way.

Problem Statement

Let MM be the set of 2n×2n2n\times 2n 0-1 matrices such that

  • All matrices have the same number of 11's
  • Any n×nn\times n submatrix has at least one 11
  • The number of 1's, kk, is the minimal possible value

Calculate kk and M\|M\|.

Solution

Minimal Number of 1's

Let A=S2n×S2nA = S_{2n}\times S_{2n} act on MM by reordering the rows and columns. Clearly, this group action is well-defined. Now consider M/A\|M/A\|, the number of different orbits. We can use one S2nS_{2n} to make the diagonal all 11's, and still have the ability to reorder the column.

Define a graph G=(N,M)G = (N, M), where N=1,,nN = \\{1,\ldots,n\\} and there is an edge from xx to yy iff (x,y)(x,y) is 11 in MM. We may assume there is a self loop on each node. Removing those 2n2n self loops, we will get a simple graph with k2nk-2n edges. Let the second S2nS_{2n} act as relabeling the nodes, so it suffices to consider unlabeled graphs. Now, the submatrix condition becomes that:

  • For any set of nn nodes, there exists an edge pointing out.

And M/A\|M/A\| is equal to the number of such simple graphs, up to isomorphism.

Clearly, nn edges does not work. But there is a solution with n+1n+1 edges: a n+1n+1 cycle plus n1n-1 isolated nodes. Thus, k=3n+1k = 3n+1.

Number of Orbits

We can prove this is the only graph.

  • If there is a cycle of length c<n+1c< n+1, then the rest 2nc2n-c elements will have only nc+1n-c+1 edges. Thus, there exists at least n1n-1 nodes that does not have an outgoing edge. Pick the cc nodes from the cycle and ncn-c nodes with 0 outgoing degree, and we get a cut.
  • If there is no cycle at all, e.g. forest, then we can simply sort nodes in the topological order and take the last nn ones.

Thus, M/A=1\|M/A\| = 1. A (somehow) surprising result.

Number of Matrices

Since there is only one orbit, M=[A:stabA(x)]\|M\| = [A: \mathrm{stab}_{A}(x)], where xx is a solution.

Without loss of generality, let xx contain the cycle 12(n+1)1\to 2\to\cdots\to (n+1) plus isolated points (n+2,n+2),,(2n,2n)(n+2,n+2),\ldots,(2n,2n). Consider stabA(x)|\mathrm{stab}_{A}(x)|:

  • We can reorder the n+2,,2nn+2,\ldots,2n rows in any permutation, as long as we do the same to those columns: (n1)!(n-1)!
  • For the cycle part, the stablizer set size is equal to automorphisms of an unlabeled cycle: 2(n+1)2(n+1)
    • It's hard to describe why verbally. But you can have a try: pick any row in the cycle to be the first row, and you'll find there are exactly 2 ways to do the rest.

Thus, the total number is M=(2n)!22(n1)!(n+1)\|M\| = \frac{(2n)!^2}{2(n-1)!(n+1)}.

We can also directly count this:

  • For the n1n-1 isolated nodes, we can insert them into any columns & rows: (2nn1)2{2n \choose n-1}^2
    • And then, we can choose the position to place 1 at each row: (n1)!(n-1)!
  • For the n+1n+1 cycle, we can shuffle the rows as a free circular permutation: 12n!\frac{1}{2}n!
    • And then each row is different so we can shuffle them: (n+1)!(n+1)!

Thus, the total number is M=12(n1)!n!(n+1)!(2nn1)2\|M\| = \frac{1}{2}(n-1)!n!(n+1)!{2n \choose n-1}^2.

PS: Complexity

If the answer is M\|M\| modulo pp, then we have a faster algorithm O(nlogn)O(\sqrt{n}\log n) via multipoint evaluation. See the next post.

Reference