Variation of the rook problem with rooks of two different colours.

187 Views Asked by At

I'm sorry if this is not actually a variation on the rook problem, but it's the most similar problem I could find.

The problem is you're given a square board which has $N \times N\ (N \geq 2)$ squares, and you have two kinds of rooks: red and blue. Each row and column must have exactly one of each colour of rook. I have found that the solution for this problem on an empty board is $N! \cdot !N$.

Is there a formula to figure out the amount of distinct solutions for a $N \times N$ grid with some pre-filled red and blue rooks as shown on this board? The amount of rooks of a single colour can vary anywhere from $0..N$ and the amount of red and blue rooks can be different.