Permutations
Straight to the problem, if n = 3,
then the lexicographic order of the permutation is :
-
1 2 3 = 1
1 3 2 = 2
2 1 3 = 3
2 3 1 = 4
3 1 2 = 5
3 2 1 = 6
You should've got the idea of what the problem is all about
.
Input and Output
There are two subtask for this problem.
- Given the index, print the assocating permutation
The input will look something like :
1 n k
- Given the permutation, print the associating index
The input will look something like :
2 n k1 k2 ... kn
Solution : (Yogy Namara)
Humble solution, not fully optimized but works fine...