As you know in STL there is a function called next_permutation, when you send a array to it, it will Rearranges the elements in the array into the next lexicographically greater permutation.
But today we need a next_k_permutation, you may say we can just apply k times next_permutation function to the array. Yes, you are right, but when k is very large it is not efficient enough.
So you are expected to write a program when given an array and k to find its next_k_permutation.
Note the next permutation of the permutation with largest dictionary order is the permutation with the minimum dictionary order. For example next permutation of (3,2,1) is (1,2,3).