II. (40 points) Given a prime number $p$ and a positive integer $n (p \geqslant n \geqslant 3)$, the set $A$ consists of different sequences of length $n$ with elements from the set $\{1,2, \cdots, p\}$ (not all elements in the same sequence are the same). If any two sequences $\left(x_{1}, x_{2}, \cdots, x_{n}\right)$ and $\left(y_{1}, y_{2}, \cdots, y_{n}\right)$ in set $A$ have three distinct positive integers $k, l, m$ such that $x_{k} \neq y_{k}, x_{l} \neq y_{l}, x_{m} \neq y_{m}$, find the maximum number of elements in set $A$.
The maximum number of elements in set $A$ is $p^{n-2}$.

Since any two sequences in set $A$ cannot have the same first $n-2$ terms (otherwise, they would differ in at most two terms, contradicting the problem statement), we have $|A| \leqslant p^{n-2}$ (since each term in the sequence has $p$ different possibilities, the maximum number of different sequences of length $n-2$ that can be formed using elements from the set $\{1,2, \cdots, p\}$ is $p^{n-2}$).

Next, we show that the number of elements in set $A$ can reach $p^{n-2}$.

Let $A_{1}$ be the set of all different sequences of length $n-2$ formed using elements from the set $\{1,2, \cdots, p\}$. Then $\left|A_{1}\right|=p^{n-2}$.
For any $\left(x_{1}, x_{2}, \cdots, x_{n-2}\right) \in A_{1}$, let
$$
x_{n-1}=\sum_{i=1}^{n-2} x_{i}(\bmod p), x_{n}=\sum_{i=1}^{n-2} i x_{i}(\bmod p) \text {, }
$$

and let the set of all resulting sequences of length $n$ be called $A$. We now prove that $A$ satisfies the problem requirements.
(1) If $\left(x_{1}, x_{2}, \cdots, x_{n-2}\right) \in A_{1}$ and $\left(y_{1}, y_{2}, \cdots, y_{n-2}\right) \in A_{1}$ already differ in at least three corresponding terms, then $\left(x_{1}, x_{2}, \cdots, x_{n}\right)$ and $\left(y_{1}, y_{2}, \cdots, y_{n}\right)$ are sequences in $A$ that differ in at least three corresponding terms.
(2) If $\left(x_{1}, x_{2}, \cdots, x_{n-2}\right) \in A_{1}$ and $\left(y_{1}, y_{2}, \cdots, y_{n-2}\right) \in A_{1}$ differ in exactly two corresponding terms, i.e., there exist $1 \leqslant k<l \leqslant n-2$ such that $x_{k} \neq y_{k}, x_{l} \neq y_{l}$. In this case, it must be that $x_{n-1} \neq y_{n-1}$ or $x_{n} \neq y_{n}$.
Assume otherwise, then
$$
x_{k}+x_{l} \equiv y_{k}+y_{l}(\bmod p)
$$

and
$$
k x_{k}+l x_{l} \equiv k y_{k}+l y_{l}(\bmod p)
$$
both hold. Thus,
$$(l-k) x_{l} \equiv (l-k) y_{l}(\bmod p)$$.
Since $1 \leqslant l-k<p$, we have $(l-k, p)=1$.
Therefore, equation (1) implies
$$
x_{l} \equiv y_{l}(\bmod p) \Rightarrow x_{l}=y_{l},
$$

which is a contradiction.
Thus, $\left(x_{1}, x_{2}, \cdots, x_{n}\right)$ and $\left(y_{1}, y_{2}, \cdots, y_{n}\right)$ differ in at least three corresponding terms.
(3) If $\left(x_{1}, x_{2}, \cdots, x_{n-2}\right) \in A_{1}$ and $\left(y_{1}, y_{2}, \cdots, y_{n-2}\right) \in A_{1}$ differ in exactly one corresponding term, i.e., there exists $1 \leqslant k \leqslant n-2$ such that $x_{k} \neq y_{k}$.
Since $1 \leqslant\left|x_{k}-y_{k}\right|<p$, we have
$$
x_{n-1}-y_{n-1} \equiv x_{k}-y_{k} \neq 0(\bmod p)$$,
$$
x_{n}-y_{n} \equiv k\left(x_{k}-y_{k}\right) \neq 0(\bmod p)$$.
This shows that $x_{n-1} \neq y_{n-1}$ and $x_{n} \neq y_{n}$.
Thus, $\left(x_{1}, x_{2}, \cdots, x_{n}\right)$ and $\left(y_{1}, y_{2}, \cdots, y_{n}\right)$ also differ in three corresponding terms.
In summary, set $A$ satisfies the problem requirements.
Combining the above two aspects, we conclude that the maximum number of elements in set $A$ is $p^{n-2}$.