12. (13 points) In 2019, a mathematics competition trial reform was implemented: a city held five joint competitions among the second-year high school students. If a student achieves a ranking in the top 20 of the city in any two of these competitions, they can enter the provincial team training and do not need to participate in the remaining competitions. Each student can participate in a maximum of five competitions. It is stipulated that if a student does not rank in the top 20 in the first four competitions, they cannot participate in the fifth competition. Assume that the probability of a student ranking in the top 20 in each competition is $\frac{1}{4}$, and the results of each competition are independent of each other.
(1) Find the probability that the student enters the provincial team;
(2) If the student enters the provincial team or completes all five competitions, let the number of competitions the student participates in be $\xi$. Find the distribution of $\xi$ and the expected value of $\xi$.
12. (1) Let “student entering the provincial team” be event $A$, and its complementary event be $\bar{A}$. Then
$$
P(\bar{A})=\mathrm{C}_{4}^{1}\left(\frac{1}{4}\right)\left(\frac{3}{4}\right)^{3}\left(\frac{3}{4}\right)+\left(\frac{3}{4}\right)^{4}=\frac{81}{128} .
$$

Thus, $P(A)=1-P(\bar{A})=1-\frac{81}{128}=\frac{47}{128}$.
(2) The possible values of the number of competitions the student participates in, $\xi$, are $2,3,4,5$. Then
$$
\begin{array}{l}
P(\xi=2)=\left(\frac{1}{4}\right)^{2}=\frac{1}{16}, \\
P(\xi=3)=\mathrm{C}_{2}^{1} \times \frac{1}{4} \times \frac{3}{4} \times \frac{1}{4}=\frac{3}{32}, \\
P(\xi=4)=\mathrm{C}_{3}^{1} \times \frac{1}{4} \times\left(\frac{3}{4}\right)^{2} \times \frac{1}{4}+\left(\frac{3}{4}\right)^{4} \\
=\frac{27}{256}+\frac{81}{256}=\frac{27}{64}, \\
P(\xi=5)=\mathrm{C}_{4}^{1} \times \frac{1}{4} \times\left(\frac{3}{4}\right)^{3}=\frac{27}{64} .
\end{array}
$$

Thus, the distribution of $\xi$ is as shown in Table 1.
Therefore, $E(\xi)$
$$
\begin{array}{l}
=2 \times \frac{1}{16}+3 \times \frac{3}{32}+4 \times \frac{27}{64}+5 \times \frac{27}{64} \\
=\frac{269}{64} .
\end{array}
$$