22. Given $n^{2}$ distinct real numbers, arranged in an $n \times n$ table, the maximum number is taken from each column and the minimum number is taken from each row. Find the number of ways to arrange these numbers so that exactly $2 n$ different numbers are selected.
Exercise B
22. For any permutation, let the element at the $i$-th row and $j$-th column be $a_{i}$. If among the $2n$ numbers taken, there are two numbers $a_{ij}$ and $a_{u}$ that are taken twice, meaning they are both the maximum in their column and the minimum in their row. Since each column has only one maximum number and each row has only one minimum number, $a_{ij}$ and $a_{k}$ must be in different rows and different columns. Thus, $a_{ij} > a_{ij} > a_{ki}$ and $a_{ij} < a_{i} < a_{i}$, which is a contradiction. Therefore, for any permutation, at most one number can be taken twice, meaning that for any permutation, at least $2n-1$ different numbers are taken. Suppose a permutation $p$ is one where exactly $2n-1$ numbers are taken, and the number taken twice in this permutation is $x$. Thus, the row and column containing $x$ have $2n-1$ different numbers, with the $n-1$ numbers in the same row as $x$ all being greater than $x$, and the $n-1$ numbers in the same column as $x$ all being less than $x$. There are $C_{n^2}^{2n-1}$ ways to choose $2n-1$ numbers from $n^2$ numbers. Among these $2n-1$ numbers, the one in the middle is set as $x$. There are $n^2$ ways to place $x$ in the $n \times n$ number table, $(n-1)!$ ways to place the $n-1$ numbers greater than $x$ in the row containing $x$, and $(n-1)!$ ways to place the $n-1$ numbers less than $x$ in the column containing $x$. There are $\left(n^2 - 2n + 1\right)!$ ways to place the remaining $n^2 - 2n + 1$ numbers in the remaining $n^2 - 2n + 1$ positions. Therefore, the number of permutations where exactly $2n-1$ numbers are taken is $C_{n^2}^{2n-1} \cdot n^2 \cdot (n-1)!(n-1)!\left(n^2 - 2n + 1\right)!$. Since there are $\left(n^2\right)!$ permutations of the $n \times n$ number table, the number of permutations where exactly $2n$ numbers are taken is $\left(n^2\right)! - C_{n^2}^{2n-1} \cdot n^2 (n-1)!(n-1)!\left(n^2 - 2n + 1\right)!$.