A rook attacks every cell in its own row and column, so a set of rooks is non-attacking when no two share a row or a column. Given a board — a chosen set of allowed cells inside an grid (the other cells are forbidden) — we want to count placements of non-attacking rooks that use only allowed cells.
Definition
Let be the number of ways to place non-attacking rooks on the allowed cells of . The rook polynomial of packages all of these counts into one generating function:
Here (the empty placement) and is just the number of allowed cells. The polynomial stops at the largest for which a placement exists, so .
Two facts that crack most konkur problems
1. Top coefficient = permanent. On a square board, placing non-attacking rooks forces exactly one rook per row and per column, i.e. a permutation with every cell allowed. So the coefficient of is
the permanent of the allowed-cell matrix (the determinant formula but with all signs).
2. Product rule for blocks. If the allowed cells split into two sub-boards that share no row and no column (disjoint blocks ), then
This lets you factor a scattered board into tiny independent pieces and multiply their polynomials.
How to apply it
Two complementary routes, depending on whether allowed or forbidden cells are sparser:
| Situation | Best tool |
|---|---|
| Few allowed cells | place rooks directly; or factor into disjoint blocks and multiply |
| Few forbidden cells | count via inclusion–exclusion over the forbidden cells |
For the inclusion–exclusion route on an board with forbidden set , the number of full permutations avoiding all forbidden cells is
where counts non-attacking rooks placed on the forbidden cells — exactly the coefficients of the rook polynomial of the forbidden board .
Mini-example
Take a board with the three diagonal cells forbidden (allowed = everything off the diagonal). The number of ways to place non-attacking rooks is the count of with for all — the derangements .
Check it with inclusion–exclusion. The forbidden diagonal is itself non-attacking, so , giving
(This is why counting permutations that dodge forbidden squares — the rook-polynomial problem — generalizes the derangement count.)
Exam trick: the coefficient of in the rook polynomial of an board is just the permanent of its allowed-cell matrix = the number of allowed full permutations. You never need the lower coefficients — when forbidden cells are few, count directly with over the forbidden board, not the whole grid.