atcoder#ARC102D. [ARC102F] Revenge of BBuBBBlesort!
[ARC102F] Revenge of BBuBBBlesort!
Score : points
Problem Statement
You are given a permutation of : . Determine if the state where for every can be reached by performing the following operation any number of times:
- Choose three elements () such that and reverse the order of these three.
Constraints
- is a permutation of .
Input
Input is given from Standard Input in the following format:
Output
If the state where for every can be reached by performing the operation, print Yes
; otherwise, print No
.
5
5
2
1
4
3
Yes
The state where for every can be reached as follows:
- Reverse the order of . The sequence becomes .
- Reverse the order of . The sequence becomes .
4
3
2
4
1
No
7
3
2
1
6
5
4
7
Yes
6
5
3
4
1
2
6
No