#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; class UnionFind{ int n; vector data; public: UnionFind(int _n):n(_n),data(_n,-1){} bool link(int a, int b){ //if new link, then true. int ra=find_root(a); int rb=find_root(b); if(ra!=rb){ if(data[rb]> N >> K; vector D; rep(i,N){ ll a; cin >> a; a--; D.push_back(a); } UnionFind uf(N); rep(i,N){ if(i!=D[i]) uf.link(i, D[i]); } map memo; rep(i,N){ memo[uf.find_root(i)]++; } ll mn = 0; FOR(it,memo){ mn += it->second - 1; } if(mn > K){ cout << "NO" << endl; }else{ if((K - mn)%2==0){ cout << "YES" << endl; }else{ cout << "NO" << endl; } } return 0; }