Permutations revisited
In previous contest you
were asked to find the k-th permutation of a series
in lexicographical order, for a given k. Now, we are asking for the inverse:
you are given a permuted series, and you need to output its order. The inputs
admit that k can have at most 15 digits.
Sample Input 1 Sample
Output 1
4 8
2 1 4 3
Sample Input 2 Sample
Output 2
5 110
5 3 1 4 2
Explanation for sample output 1:
1 2 3 4
// First permutation
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3 //
8th permutation