1. It is known that an $n \times n \times n$ cube is composed of $n^{3}$ unit cubes (referred to as "cells"). For any two cells $A$ and $B$, if they share a common face, or there exists a cell $C$ such that $A$ and $B$ both share a common face with $C$, then the cells $A$ and $B$ are called "adjacent". Now, each cell of the $n \times n \times n$ cube is colored with one of $r$ colors, such that any two adjacent cells have different colors. Find the minimum value of $r$.
If two cells have a common face, they are called adjacent, and one is called a neighbor of the other. The set consisting of $A$ and its neighbors is called the neighborhood of $A$.
It is easy to see that when $n=1$, the minimum value of $r$ is 1;
when $n=2$, the minimum value of $r$ is 4.
When $n \geqslant 3$, consider one of the $3 \times 3 \times 3$ cubes, the center cell of which shares a common face with six other cells. These seven cells are pairwise adjacent, either directly or through the center cell. Therefore, $r \geqslant 7$. Let $A(x, y, z)$ represent the cell located at the $x$-th layer, $y$-th row, and $z$-th column of the cube. Define the index function $f(A)=x+2 y+3 z$, then the function values of $f(A)$ and the other six cells in its neighborhood form a complete residue system modulo 7. Color the cell $A(x, y, z)$ that satisfies $f(A) \equiv i(\bmod 7)$ with the $i$-th color $(i=1,2, \cdots, 7)$, so that any two cells in the neighborhood of $A$ have different colors. Thus, $r=7$ meets the requirement. Therefore, the minimum value of $r$ is 7.
Hence, $r_{\min }=\left\{\begin{array}{ll}n^{2}, & n \leqslant 2 ; \\ 7, & n \geqslant 3 .\end{array}\right.$