Three, set $S=\{x \mid x$ is a 9-digit number in decimal, digits are $1,2,3\}$. Mapping $f: S \longrightarrow\{1,2,3\}$, and for any pair of $x, y$ in $S$ with different digits at the same position, $f(x) \neq f(y)$. Find $f$ and its number.
Three $S$ can be regarded as the set of 9-element ordered arrays $\left(x_{1}, x_{2}, \cdots, x_{9}\right)$, where $x_{i} \in\{1,2,3\}, 1 \leqslant i \leqslant 9$.
Let $S_{j}$ be the set of elements in $S$ that map to $j(j=1,2,3)$, then $S_{1}, S_{2}, S_{3}$ is a partition of $S$, and any two elements $x, y$ in $S_{j}$ have at least one identical component. The problem is to find the number of such partitions.
Let $S_{i}=\{$ 9-element arrays with $i$ as the first element $\}(i=1,2,3)$. Clearly, such $S_{i}$ meet the conditions. The first element can be any element, and $S_{1}, S_{2}, S_{3}$ can be arranged in any order. Therefore, we have already provided $9 \times 3!=54$ examples that meet the requirements.
Conjecture: There are only the above cases. Proof as follows:
Without loss of generality, assume $(1,1, \cdots, 1) \in S_{1},(2,2, \cdots, 2) \in S_{2},(3,3, \cdots, 3) \in S_{3}$.
Suppose $x \in S_{1}$, and the first element of $x$ is 1, denote $x$ as $1+y$, where $y$ is the 8-element vector (array) formed by the last 8 elements of $x$.
If $2+y \in S_{2}$, we will prove that all arrays with 2 as the first element are in $S_{2}$.
In fact, let this array be $2+u$, then there is an 8-element array $v$, each element of which is different from $y$ and also different from $u$, so $3+v \notin S_{1}, 3+v \notin S_{2}, 3+v \in S_{3}$. Thus, $2+u \notin S_{3}$. Also, $1+v \notin S_{2}$. And there is an 8-element array $w$, each element of which is different from $y$ and also different from $v$, clearly $3+w \in S_{3}$, thus $1+v \in S_{1}, 2+u \notin S_{1}$. Therefore, $2+u \in S_{2}$ must hold.
It is easy to see that at this time, $S_{2}$ contains only arrays with 2 as the first element, and $S_{1}, S_{3}$ are composed of arrays with 1,3 as the first element, respectively.
Therefore, if $21 \cdots 1 \in S_{2}$, the conclusion is already established. Suppose $21 \cdots 1 \in S_{1}$, similarly if $221 \cdots 1 \in S_{2}$, then by the above reasoning (replacing the first element with the second element), $S_{i}$ is composed of arrays with $i$ as the second element. Suppose $221 \cdots 1 \in S_{1}$. Proceeding in this manner, until $22 \cdots 21 \in S_{1}$. But at this time $22 \cdots 22 \in S_{2}$, so $S_{i}$ is composed of arrays with $i$ as the last element.