Score : $1200$ points
You are given a permutation of $1,2,...,N$: $p_1,p_2,...,p_N$. Determine if the state where $p_i=i$ for every $i$ can be reached by performing the following operation any number of times:
Input is given from Standard Input in the following format:
$N$ $p_1$ $:$ $p_N$
If the state where $p_i=i$ for every $i$ can be reached by performing the operation, print Yes
; otherwise, print No
.
5 5 2 1 4 3
Yes
The state where $p_i=i$ for every $i$ can be reached as follows:
4 3 2 4 1
No
7 3 2 1 6 5 4 7
Yes
6 5 3 4 1 2 6
No