A ghost leg is a game with some vertical lines and some horizontal lines. A player starts at the top of the vertical line and go downwards, and always walkthrough a horizontal line if he encounters one. We define a layer is some horizontal line with the same height and has no duplicated endpoints. Find the smallest number of layers needed to grant that you can walk from $(1, 2, \ldots , n)$ on the top to any permutation $(\sigma_1, \sigma_2, \ldots, \sigma_n)$ on the bottom.
Problem
Source: IMOC 2023 C4
Tags: combinatorics
CrazyInMath
09.10.2023 20:12
We claim the answer is $n$.
First. We notice that if the permutation was totally reversed (i.e. $(n,n-1,\cdots,1)$), then we need $\frac{n(n-1)}{2}$ swaps.
If $n$ is even, each layer offers $\frac{n}{2}$ swaps, so at least $n$ layers for even $n$. If $n$ is odd, each layer offer a maximum of $\frac{n+1}{2}$ swaps, we call this a full layer. However, if you draw it out you'll know that two full layers can't be adjacent or they will just cancel out each other. So a layer adjacent to a full layer can offer at most $\frac{n-1}{2}$ swaps. So $n$ layer is required for odd $n$ as well.
Call the lines $L_1,L_2,\cdots, L_n$. For even $n$ we can construct a $n$-layer ghost leg as follow: if $i$ is even, then the $i$th layer would draw horizontal lines from lines $3$ mod $4$ to $0$ mod $4$ and $1$ mod $4$ to $2$ mod $4$. If $i$ is odd then it would draw horizontal lines from lines $2$ mod $4$ to $3$ mod $4$ and $0$ mod $4$ to $1$ mod $4$.
For odd $n$, alternate full layers and non-full layers. The lines in the non-full layers must not be directly below a horizontal line of an adjacent full-layer.
This gives construction for all $n$ if the sequence if completely reversed.
Now assume there are some $S=(\sigma_1, \sigma_2,\cdots, \sigma_n)$ that cannot correspond to a ghost leg. Moreover, we assume this one has the most reversed pairs. Now take a non-reversed pair $\sigma_k, \sigma_{k+1}$, we know that $S'=(\sigma_1,\sigma_2,\cdots, \sigma_{k+1}, \sigma_{k},\cdots, \sigma_n)$ can correspond to a ghost leg. Moreover, there would be a line that swaps $\sigma_k$ and $\sigma_{k+1}$ in $S'$, as each reversed pair corresponds to a swap. So if we remove that line, we know that $S$ can correspond to a ghost leg, contradiction.
So each permutation can be corresponded to a ghost leg at most $n$ layers.