#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ALL(a) (a).begin(), (a).end() using ll = long long; using P = pair; #define int ll struct State { int v, cost; State(int v, int cost): v(v), cost(cost) {} // 昇順 bool operator<(const State& s) const { return cost < s.cost; } // 降順 bool operator>(const State& s) const { return cost > s.cost; } }; void dump_vector(vector vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << (i < vec.size() - 1 ? " " : "\n"); } } signed main() { int n; ll k; cin >> n >> k; vector d(n); for (int i = 0; i < n; i++) { cin >> d[i]; d[i]--; } ll swap_cnt = 0; for (int i = 0; i < n; i++) { if (d[i] != i) { /* cout << i << "でswap" << endl; cout << "現在" << d[i] << " これと交換するのは" << d[d[i]] << endl; */ swap_cnt++; swap(d[i], d[d[i]]); } } // cout << "swap回数は" << swap_cnt << endl; // 2でswapできるだけswap if (swap_cnt > k) { cout << "NO" << endl; } else if ((k - swap_cnt) % 2 == 0) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }