Alice and Bob frequently take long road trips to get to various programming competitions in their area. Since everything's bigger in the state that they live in, they have turned to playing car games to pass the time.
Alice and Bob are both computer scientists, so they quickly tired of "guess the number", as the guesser could always identify the number using a logarthmic number of guesses. To up the challenge, they created a new game: "guess the permutation".
A permutation of length N is an arrangement of the numbers 1,…,N. For a given permutation P, define inv(l,r) to be the number of pairs (i,j) with l≤i≤j≤r such that P_i>P_j.
When playing this game, Alice thinks of a permutation, and Bob can ask Alice the result of the function inv for up to N inputs.
Can you help Bob figure out Alice's permutation P?