```
vector<int> dp(n+1,INT_MAX); //it'll store the minimum values as you require
//thes two multisets will store the dp values of the range [i-k,i) according to there parity of values so that you can get the minimum in the range as per the parity of current i
multiset<int> evens,odds;
//just setting up the initial values where we can reach without considering parity and inserting them in multiset as per parity
for(int i=1;i<=k;i++){
dp[i]=1;
if(v[i]%2==0) evens.insert(dp[i]);
else odds.insert(dp[i]);
}
//now the final transitions begin we find the minimum in range [i-k,i) as per the parity in the multiset
for(int i=k+1;i<=n;i++){
//if v[i] is even well look in even multiset and after querying and doing necessary transition will add it to multiset
if(v[i]%2==0){
if(!evens.empty()) dp[i]=(*evens.begin()+1);
evens.insert(dp[i]);
}
//similarly for odd
else{
if(!odds.empty()) dp[i]=(*odds.begin()+1);
odds.insert(dp[i]);
}
//now the (i-k)th index won't be available for transition anymore so remove it from its respective set
if(v[i-k]%2==0){evens.erase(evens.find(dp[i-k]));}
else {odds.erase(odds.find(dp[i-k]));}
}
```

Some things to care during implementation

Remember it’ll have minimum moves for N and we need to find for N+1 to which we can make transition from any of the last k positions so query for the minimum is the last k dp values and return min+1 as ans.

(If min is greater than or equal to INT_MAX return -1