Special permutations

Правка en1, от vicpall, 2018-09-19 21:59:46

I'm trying to solve the following problem: "We call a permutation a set of 2*n numbers (A[1], A[2], ... , A[n], A[n+1], A[n+2], ... , A[2*n]) such that: a) A[1]<A[2]<...<A[n] b) A[n+1]<A[n+2]<...<A[2*n] c) A[1]<A[n+1], A[2]<A[n+2],... A[n]<A[2*n]

There are 2 types of questions: a) given the size of the permutation (n), and the permutation itself, find the position of the permutation (see the example below) b) given the size of the permutation (n) and a number i, find the ith permutation

For example, if n=3 the permutations are: 1 2 3 4 5 6 1 2 4 3 5 6 1 2 5 3 4 6 1 3 4 2 5 6 1 3 5 2 4 6.

So, if the type of the question is a), n is 3 and the permutation is 1 3 4 2 5 6, then the answer is 4. If the type of the question is b), n is 3 and i is 4, then the answer is 1 3 4 2 5 6."

Can you help me, at least give me a hint?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский vicpall 2018-09-19 22:01:06 6 (published)
en1 Английский vicpall 2018-09-19 21:59:46 886 Initial revision (saved to drafts)