#include using namespace std; int main() { //人数Nと操作Kを宣言 int N; long K; cin >> N >> K; //数列用の動的配列を設定 int* const array = new int[N]; //動的配列arrayを設定 //arrayに数値を設定 for (int i = 0; i < N; i++) { cin >> array[i]; } //操作の必要最小回数を算出 int operation = 0; for (int i = 0; i < N; i++) { if (array[i] == i + 1) { //何もしない } else { //i+1と同じ値が入ってる要素のindex int _i = i + 1; while (array[_i] != i + 1) { _i++; } array[_i] = array[i]; operation++; } } //YESかNOかの判定 if (operation > K || K % 2 != operation % 2) { cout << "NO" << endl; } else { cout << "YES" << endl; } delete[] array; //動的配列arrayを解放 return 0; }