KonkurStudy
همه کارت‌ها

Rook Polynomials and Non-Attacking Rooks

The rook polynomial counts non-attacking rook placements on a board with forbidden squares; its top coefficient is the permanent of the allowed-cell matrix.

کارت مفهوم کنکور ارشد علوم کامپیوتر

اهمیت
۰/۵

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 BB — a chosen set of allowed cells inside an m×nm\times n grid (the other cells are forbidden) — we want to count placements of kk non-attacking rooks that use only allowed cells.

Definition

Let rk(B)r_k(B) be the number of ways to place kk non-attacking rooks on the allowed cells of BB. The rook polynomial of BB packages all of these counts into one generating function:

RB(x)=∑k≥0rk(B) xk=r0+r1x+r2x2+⋯R_B(x)=\sum_{k\ge 0} r_k(B)\,x^{k}=r_0 + r_1 x + r_2 x^{2}+\cdots

Here r0=1r_0=1 (the empty placement) and r1r_1 is just the number of allowed cells. The polynomial stops at the largest kk for which a placement exists, so deg⁡RB≤min⁡(m,n)\deg R_B \le \min(m,n).

Two facts that crack most konkur problems

1. Top coefficient = permanent. On a square n×nn\times n board, placing nn non-attacking rooks forces exactly one rook per row and per column, i.e. a permutation σ∈Sn\sigma\in S_n with every cell (i,σ(i))(i,\sigma(i)) allowed. So the coefficient of xnx^{n} is

rn(B)=per⁡(M),Mij={1(i,j) allowed0forbidden,r_n(B)=\operatorname{per}(M),\qquad M_{ij}=\begin{cases}1 & (i,j)\text{ allowed}\\ 0 & \text{forbidden,}\end{cases}

the permanent of the 0/10/1 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 B1,B2B_1,B_2), then

RB1∪B2(x)=RB1(x)⋅RB2(x).R_{B_1\cup B_2}(x)=R_{B_1}(x)\cdot R_{B_2}(x).

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 RBi(x)R_{B_i}(x)
Few forbidden cells count via inclusion–exclusion over the forbidden cells

For the inclusion–exclusion route on an n×nn\times n board with forbidden set FF, the number of full permutations avoiding all forbidden cells is

rn=∑j≥0(−1)j rj(F) (n−j)!,r_n = \sum_{j\ge 0}(-1)^{j}\,r_j(F)\,(n-j)!,

where rj(F)r_j(F) counts jj non-attacking rooks placed on the forbidden cells — exactly the coefficients of the rook polynomial of the forbidden board FF.

Mini-example

Take a 3×33\times 3 board with the three diagonal cells (1,1),(2,2),(3,3)(1,1),(2,2),(3,3) forbidden (allowed = everything off the diagonal). The number of ways to place 33 non-attacking rooks is the count of σ∈S3\sigma\in S_3 with σ(i)≠i\sigma(i)\ne i for all ii — the derangements D3=2D_3=2.

Check it with inclusion–exclusion. The forbidden diagonal is itself non-attacking, so rj(F)=(3j)r_j(F)=\binom{3}{j}, giving

r3=∑j=03(−1)j(3j)(3−j)!=6−3⋅2+3⋅1−1=2. ✓r_3=\sum_{j=0}^{3}(-1)^{j}\binom{3}{j}(3-j)! = 6 - 3\cdot 2 + 3\cdot 1 - 1 = 2.\ \checkmark

(This is why counting permutations that dodge forbidden squares — the rook-polynomial problem — generalizes the derangement count.)

Exam trick: the coefficient of xnx^{n} in the rook polynomial of an n×nn\times n 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 rn=∑j(−1)jrj(F)(n−j)!r_n=\sum_j(-1)^j r_j(F)(n-j)! over the forbidden board, not the whole grid.

فرمول‌های کلیدی

Rook polynomial
RB(x)=∑k≥0rk(B) xkR_B(x)=\sum_{k\ge 0} r_k(B)\,x^{k}

Generating function whose x^k coefficient r_k(B) counts placements of k non-attacking rooks on the allowed cells of board B.

Top coefficient = permanent
rn(B)=per⁡(M),Mij=[(i,j) allowed]r_n(B)=\operatorname{per}(M),\quad M_{ij}=[(i,j)\text{ allowed}]

On an n*n board the coefficient of x^n equals the permanent of the 0/1 allowed-cell matrix, i.e. the number of allowed permutations in S_n.

Disjoint-block product rule
RB1∪B2(x)=RB1(x)⋅RB2(x)R_{B_1\cup B_2}(x)=R_{B_1}(x)\cdot R_{B_2}(x)

If two sub-boards share no row and no column, the rook polynomial of their union is the product of the individual polynomials.

Inclusion-exclusion over forbidden cells
rn=∑j≥0(−1)j rj(F) (n−j)!r_n=\sum_{j\ge 0}(-1)^{j}\,r_j(F)\,(n-j)!

Full permutations of an n*n board avoiding the forbidden set F, where r_j(F) counts j non-attacking rooks on the forbidden cells.

#rook-polynomial#non-attacking-rooks#permanent#inclusion-exclusion#derangement#combinatorics

سوالات تمرینی