Example 1 In an $n \times n$ chessboard $C$, a number is filled in each cell, and the numbers filled in the edge cells of the board are all -1. For any other empty cell, fill it with the product of the two closest filled numbers on its left and right in the same row or above and below in the same column. Find the maximum number of 1's in the table, denoted as $f(n)$, and the minimum number of 1's, denoted as $g(n)$. (20th All-Russian Mathematical Olympiad Problem)
\begin{tabular}{|c|c|c|c|c|c|}
\hline-1 & -1 & -1 & -1 & -1 & -1 \\
\hline-1 & $a$ & & & $b$ & -1 \\
\hline-1 & & & & & -1 \\
\hline-1 & $e$ & & & & -1 \\
\hline-1 & $d$ & $f$ & $\wedge$ & $c$ & -1 \\
\hline-1 & -1 & -1 & -1 & -1 & -1 \\
\hline
\end{tabular}
Analysis and Solution First, it is clear that $f(3)=g(3)=1$.
When $n>3$, we hope that 1 appears as much as possible. Can they all be 1? Through attempts, we find that there must be at least one -1. In fact, consider the -1 cells tightly surrounding the outermost layer, among which at least one cell is filled with -1. Otherwise, consider the cells $a, b, c, d$ in the table, and assume that the last cell to be filled is $d$. If $a, b, c$ are all filled with 1, then no matter when $d$ is filled, it can only be -1, which is a contradiction.

Thus, $f(n) \leqslant(n-2)^{2}-1$.
Next, by the row product, $a$ can be filled with 1, and by the column product, $b$ can be filled with 1. Then, by the row product again, $e$ and $c$ can be filled with 1, and by the column product, $f$ can be filled with 1. This way, $d$ is filled with -1. For the other cells, the second row and the second-to-last row can all be filled with 1 by the row product, and the remaining cells can all be filled with 1 by the column product. At this point, there are a total of $(n-2)^{2}-1$ ones. Therefore, $f(n)=(n-2)^{2}-1$.

Next, we prove that when $n>3$, $g(n)=n-2$.
If $g(n)=r \leqslant n-3$, then the $r$ ones can occupy at most $n-3$ rows and $n-3$ columns. Therefore, in the middle $n-2$ rows and $n-2$ columns, there must be one row and one column that are all -1, but this is impossible because their intersection cannot be filled with -1, leading to a contradiction. Therefore, $g(n) \geqslant n-2$.

On the other hand, fill the $n-2$ cells in the second column with 1 (fill by row), and then for each row, fill -1 from right to left by row. At this point, the table contains a total of $n-2$ ones. Hence, $g(n)=n-2$.

In summary,
$$\begin{array}{l}
\text { In summary, } \quad f(n)=\left\{\begin{array}{ll}
1 & (n=3) ; \\
(n-2)^{2}-1 & (n>3) .
\end{array}\right. \\
g(n)=n-2 .
\end{array}$$