For a sequence, one can perform the following operation: select three adjacent terms $a,b,c,$ and change it into $b,c,a.$ Determine all the possible positive integers $n\geq 3,$ such that after finite number of operation, the sequence $1,2,\cdots, n$ can be changed into $n,n-1,\cdots,1$ finally.
Problem
Source: China Girls Math Olympiad 2019 Day 1 P3
Tags: combinatorics
12.08.2019 15:16
The key note is that when applying an operation of the given type the number of inversions is invariant $\mod 2$ hence $2|n(n-1)/2$. Then proving it for $4$ and $1$ and using induction $n \rightarrow n+4$ we are done.
12.08.2019 15:31
13.08.2019 09:30
We notice $(a,b,c) \rightarrow (b,c,a)$, make the inversion number add $\pm1 \pm1=-2,0,2$. Let the inversion number of $a_1, a_2, \cdots, a_n$ is $f(a_1, a_2, \cdots, a_n)$, then, $$f(1, 2, \cdots, n)=0,$$$$f(n, n-1, \cdots, 1)=(n-1)+(n-2)+\cdots+1=\frac{n(n-1)}{2}.$$It follows that $2 \mid \dfrac{n(n-1)}{2}$, $4 \mid n(n-1)$, $gcd(n,n-1)=1$, we get $4 \mid n$ or $4 \mid n-1$, $n \equiv 0,1 (mod4)$. We notice: if $n=4k$ is okay, consider the case of $4k+1$ we can lift $1$ to the end, get $(2,3,\cdots,4k+1,1)$, then, do the operation as same as $4k$ to $(2,3,\cdots,4k+1)$, we only need to do $n=4k$. Induction on $k$: (1) when $k=1$, $1234 \rightarrow 1423 \rightarrow 4213 \rightarrow 4132 \rightarrow 4321$. {\bf (2)} if $k(\geq 1)$ is okay, now we do $4(k+1)$: First we make: $$(1,2,\cdots,4k,4k+1,4k+2,4k+3,4k+4) \rightarrow (1,2,\cdots,4k,4k+4,4k+3,4k+2,4k+1),$$now we lift $(4k+4, 4k+3)$ to the first, lift $(4k+2, 4k+1)$ to the third and fourth and we can do it. So, $n \equiv 0,1 (mod4)$.
21.01.2020 21:51
Can you explain how did you prove that there are no other solutions except for these two?
21.05.2020 01:43
@ above Let $ x $ be the number of pairs $(a, b) $ where $a<b $ but $b$ to the right of $a$. note that $x$ is zero in the beginning and $\frac{n(n-1)} {2}$ in the end , and $x$ changes by $ 2, - 2 $ or $0 $ in each move. So $2| \frac{n(n-1)} {2}$, hence $n=0,1 mod 4 $.
29.05.2024 18:29
Solved with MathLuis. This solution deals with the move $(a,b,c)$ to $(c,a,b)$ which is the same problem really only we worked with this version. This gsolve as always consisted of us yapping for a good 3 hours about some nonsense. We claim that the answer is all $n\equiv 0,1 \pmod{4}$. We say that a positive integer $n$ is good if it is possible to reach $n,n-1,\dots,1$ from $1,2,\dots, n$ using only moves of the allowed type. We first show that all $n$ of the claimed forms are indeed good. We show this via induction. First note that $4$ and $5$ are both good since \begin{align*} 1 &2 3 4\\ & \downarrow\\ 4 &1 3 2\\ & \downarrow\\ 4 &2 1 2\\ & \downarrow\\ 4 &3 2 1 \end{align*}and \begin{align*} 1 2 &3 4 5\\ & \downarrow\\ 1 2 &5 3 4\\ & \downarrow\\ 5 1 &2 3 4 \end{align*}from which we know we can reach $5,4,3,2,1$ since $4$ is known to be good. Now, we show that if $n$ is good for some even $n$, then so are both of $n+4$ and $n+5$. First, consider the move \[(a,b,c) \rightarrow (c,a,b)\]for adjacent numbers in this set. Thus, we can pick any three adjacent integers, and swap the first two pair and the third number. By applying this move multiple times, on $1,2,3,4,\dots,$ we can, \begin{align*} 1 2 &3 4 \dots\\ \downarrow \\ 3 1& 2 4 \dots \\ \downarrow \\ 3 4 & 1 2 \dots \end{align*}etc. until the pair $1,2$ has been moved to the rightmost position of the sequence. Thus, repeating this same process for the first $r$ pairs, we can move the leftmost block of $2r$ numbers ($1,2,\dots,2r$) to the rightmost position. Now, since $n$ is even, 1. For $n+4$, we can move the first $n$ numbers to the rightmost end to obtain, \[n+1 , n+2 , n+3 , n+4 , 1 , 2 , 3, \dots, n\]which since both $4$ and $n$ are good, we can reverse the first 4 numbers, and the last $n$ numbers to obtain \[n+4 , n+3 ,\dots, 2,1\]proving that $n+4$ is also good. 2. For $n+5$, similarly we can move the first $n$ numbers to the rightmost end to obtain, \[n+1,n+2,n+3,n+4,n+5,1,2,\dots,n\]which since both $5$ and $n$ are good, we can reverse the first 5 numbers, and the last $n$ numbers to obtain \[n+5 , n+4 , n+3 ,\dots, 2,1\]proving that $n+5$ is also good. Now, we know that $4$ is good. By (1) above it follows that all $n\equiv 0 \pmod{4}$ are good. Then, using (2) it follows that all $n\geq 9$ and $n\equiv 1 \pmod{4}$ are also good. Since we know that $5$ is good, we are done. Now, we shall show that all other $n$ are not good. For this, we start off by proving the following key claim. Claim : The parity of the number of inverted pairs in the given set of integers is invariant under the given operation. Proof : This is a nasty check. Consider a move done on the triple $(a,b,c)$ any inverted pair involving two numbers neither of which are in this triple remains unchanged after the move since the relative positions of these numbers is unaffected by our move. Now, consider inverted pairs where exactly one of the numbers involved is in this triple. Say the other number of the inverted pair is $p$. We have 4 cases. Case 1 : $p$ is to the left of $a$. Then, the given move does, \[(p,a,b,c) \rightarrow (p,c,a,b)\]But note that after this, the relative positions of each of $a,b,c$ with $p$ remain unchanged (they are all to the right of it before and after the move) so the number of inverted pairs remains unchanged. Case 2 : $p$ lies in between $a$ and $b$. Then, the given move does \[(a,p,b,c) \rightarrow (c,p,a,b)\]Here, the relative position of $b$ with respect to $p$ has no changed so any inverted pair related to these two does not change. Pairs $(a,p)$ and $(p,c)$ have their directions swapped, so if both were inverted before the move none is afterwards and vice versa. If exactly one was inverted, that will be non-inverted while the other becomes inverted. Thus, the number of inverted pairs is invariant $\pmod{2}$ in this case as well. Case 3 : $p$ lies between $b$ and $c$. Similar to Case 2. Case 4 : $p$ lies to the right of $c$. Similar to the Case 1. Now we are left to check the inverted pairs among $a$ , $b$ and $c$. Here too we have 6 cases to check. Case 1 : $a>b>c$. Here the number of inverted pairs changes from 2 to 0. Case 2 : $a>c>b$. Here the number of inverted pairs remains constant as 1. Case 3 : $b>a>c$. Here the number of inverted pairs changes from 1 to 3. Case 4 :$ b>c>a$. Here the number of inverted pairs is constant 2. Case 5 : $c>a>b$. Here the number of inverted pairs changes from 2 to 0. Case 6 : $c>b>a$. Here the number of inverted pairs changes from 3 to 1. In all cases the parity of the number of inverted pairs is unaffected by the given moves, which finishes the proof of the claim. Now, note that clearly in the start the number of inverted pairs is 0 while the number o inverted pairs at the end is $\binom{n}{2}$. It is then not hard to see that $\binom{n}{2}\equiv 0 \pmod{2}$ if and only if $n\equiv 0,1 \pmod{4}$ which finishes the problem.
07.01.2025 07:54
Very cute problem Only numbers of type $4k$ and $4k+1$ works. Note that for $n=4$ we have \[ 1,2,3,4 \rightarrow 1,3,4,2 \rightarrow 1,4,2,3 \rightarrow 4,2,1,3 \rightarrow 4,1,3,2 \rightarrow 4,3,2,1 \] Claim : $a,b,c,d,x \Rightarrow x,a,b,c,d$ \[ a,b,c,d,x \rightarrow a,b,x,c,d \rightarrow x,a,b,c,d \] Hence if $n=4k$ then we take $k$ blocks on $4$ numbers. Then take last $n-3,n-2,n-1,n$ to leftmost side and make it $n,n-1,n-2,n-3$ by applying same swaps as for $n=4$. Now do this for all $k$ blocks and we get $(n,n-1,\cdots 2,1)$. Note for $n=4k+1$ we can send $n$ to leftmost side as there are $n-1$ number in between, which is even numbers by applying operation on same set. Which give us $(a,b,c) \rightarrow (c,a,b)$. After that we left with $4k$ number, which we can reverse by induction. We show contradiction for other type of numbers. Here is look result you should always know Consider permutation $\sigma$. Consider graph $G$ on $n$ vertices such that $\sigma : i \rightarrow \sigma(i)$. Let $C$ denote the number of cyclic in this graph. Lemma : If you swap $x\Rightarrow y$ in permutation, Then we get $C+1$ or $C-1$. Proof : Suppose $x$ and $y$ are in different cycle. Let there cycle be $$x \rightarrow u_1 \rightarrow u_2 \rightarrow \cdots \rightarrow u_p \rightarrow x$$and for $y$ we have $$y \rightarrow v_1 \rightarrow v_2 \rightarrow \cdots \rightarrow v_q \rightarrow y$$Now if we swap $x$ and $y$ we will have $$x \rightarrow u_1 \rightarrow u_2 \cdots \rightarrow u_p \rightarrow y \rightarrow v_1 \rightarrow v_2 \rightarrow \cdots \rightarrow v_q \rightarrow x$$hence we get $C \rightarrow C-1$. Note this is only change will happen in whole structure of graph. Similarly for case when $x$ and $y$ are in same cycle initially $$x \rightarrow u_1 \rightarrow \cdots \rightarrow u_p \rightarrow y \rightarrow v_1 \rightarrow \cdots \rightarrow v_q \rightarrow x$$Then swapping $x$ and $y$ give us $$x \rightarrow u_1 \rightarrow \cdots u_p \rightarrow x$$$$y \rightarrow v_1 \rightarrow \cdots \rightarrow v_q \rightarrow y$$hence $C \rightarrow C+1$. Now for $(a,b,c) \rightarrow (b,c,a)$ we need $2$ swaps. Hence $C \rightarrow \{C-2,C,C+2\}$ which tells us $C \equiv \pmod 2$ never change. For $(1,2\cdots n)$, number cycles are $n$ (self loops) and for $(n,n-1\cdots 2,1)$, number of cycles are $\left\lceil \frac{n}{2} \right\rceil +1$ Thus for $$n \equiv \left\lceil \frac{n}{2} \right\rceil +1 \pmod 2$$we should have $n \equiv {0,1} \pmod 4$