atcoder#ABC254C. [ABC254C] K Swap
[ABC254C] K Swap
Score : points
Problem Statement
We have a sequence of length : . Additionally, you are given an integer .
You can perform the following operation zero or more times.
- Choose an integer such that , then swap the values of and .
Determine whether it is possible to sort in ascending order.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to sort in ascending order, print Yes
; otherwise, print No
.
5 2
3 4 1 3 4
Yes
The following sequence of operations sorts in ascending order.
- Choose to swap the values of and . is now .
- Choose to swap the values of and . is now .
5 3
3 4 1 3 4
No
7 5
1 2 3 4 5 5 10
Yes
No operations may be needed.