In a running race, three people started: $X, Y$, and $Z$. $X$ performed the best, $Y$ came in second, while $Z$ lagged a bit behind. During the race, $Z$'s position changed six times, $X$'s position changed five times, and in the end, $Y$ reached the finish line before $X$.

What was the final result of the race?
To ensure the clarity of the task, let's first define the meaning of position and position change in the context of dead heats as follows: only actual overtakes are considered as position changes. That is, if, for example, $X$ is in first place, $Y$ is in second, and $Y$ catches up to $X$, $X$'s position remains first, and $Y$'s remains second. A swap only occurs if $Y$ also passes $X$. In this light, if $X$ catches up to $Y$, and then they both overtake $Z$ simultaneously, the order first becomes $(Z Y X)$, then $(Y Z X)$, and finally $(Y X Z)$. Thus, $Z$'s position changes twice, while the others' change once during this period. In this way, every position change is precisely an event between two competitors; furthermore, there is no dead heat, as among two adjacent competitors, the one who is overtaken is considered to be further ahead.

Turning to the solution of the problem, according to the text, the order immediately after the start was $X Y Z$. If any of their positions changed once, it could only change to an opposite parity. Therefore, with an odd number of position changes, a competitor would end up in a position of opposite parity to their starting position, and with an even number of changes, in a position of the same parity.

Since $X$ was initially in first place and their position changed an odd number of times, they could only have finished in an even-numbered position, i.e., second. According to the last condition, $Y$ overtook $X$, so $Y$ must have been the winner, while $Z$ took third place. The following example shows one possible sequence of position changes:

\[
\begin{array}{r}
\text { I } X X X Y Y Y Y Y y \\
\text { II } Y Z Y Y X Y X Y Y \\
\text { III } Z Y Z Z X Y X Y
\end{array}
\]

It is clear that $X$'s position changed five times, and $Z$'s position changed six times - the latter was not necessary for the conditions (but would have led to a contradiction if $Z$'s position had also changed an odd number of times).

Note. If we did not handle dead heats in the above manner, the solution would not necessarily be unique.

![](https://cdn.mathpix.com/cropped/2024_05_02_3ca9227b5b1a4c36fc54g-1.jpg?height=84&width=1786&top_left_y=1151&top_left_x=164)
Since $X$'s position, which changed an odd number of times, ended up in a position of the same parity as the starting position, it is not necessarily the case that $X$ finished second in the race. An example of this is the following:

![](https://cdn.mathpix.com/cropped/2024_05_02_3ca9227b5b1a4c36fc54g-1.jpg?height=156&width=454&top_left_y=1337&top_left_x=833)

Based on the work of Ágnes Fehér (Miskolc, Földes F. Gymnasium, 1st year)