There are $n$ boys, $n$ dads and $n$ moms. In how many ways can these $3n$ people be grouped into groups of one boy, one dad and one mom with no boy grouped with both of his parents?
The given answer was $$\sum_{r=0}^n(-1)^r\binom nr((n-r)!)^2$$ I have learnt the generalised inclusion–exclusion principle:
Theorem 4.3.1. (GPIE) Let $S$ be an $n$-element set and let $(P_1,P_2,\dots,P_q)$ be a set of $q$ properties for elements of $S$. Then for each $m=0,1,2,\dots,q$, $$\begin{align}E(m)&=\omega(m)-\binom{m+1}m\omega(m+1)+\binom{m+2}m\omega(m+2)-\dots+(-1)^{q-m}\binom qm\omega(q)\\ &=\sum_{k=m}^q(-1)^{k-m}\binom km\omega(k).\tag{4.3.1}\end{align}$$
But how do I use this to derive the given answer?
Consider the number of ways of forming $n$ groups with each group having a mom, dad, boy. First we put the dads one in each group. Then we place the moms in $n!$ ways and the boys in $n!$ ways. Thus the total number of ways is $\{n!\}^2$.
For $1 \leq r \leq n$, let $A_r$ denote the event in which $r$ groups violate the condition. Then these groups have mom, dad and boy together. Let us count the number of ways the other $n-r$ groups can be formed. First place the dads in $n-r$ groups. This can be done in one way. Then the moms can be placed in $(n-r)!$ ways and the boys can be placed in $(n-r)!$ ways. Thus the other groups can be formed in $\{(n-r)!\}^2$ ways. Now, by PIE, we have \begin{align*} |A_1^c\cap A_2^c \cdots \cap A_n^c| &= \{n!\}^2 - \binom{n}{1}\{(n-1)!\}^2 + \binom{n}{2}\{(n-2)!\}^2 - \cdots \end{align*}