HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC - 2013-2014 > problem:


14-07-20. 50384 - Permutations revisited

IMPC - 2013-2014

Start: Mar.16.2013 at 12:00:00 PM
Finish: Mar.16.2013 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 14-05-50. 50414 - Traffic
• 14-05-50. 50421 - Repairing road s...
• 14-05-60. 50371 - Modified Karnaug...
• 14-05-70. 50477 - Character Pyramids
• 14-05-80. 50372 - Number Quadrup...
• 14-05-90. 50549 - k-Nearest Neigh...
• 14-05-95. 50479 - Bit Compressor
• 14-07-10. 50383 - Noisy Mornings
• 14-07-20. 50384 - Permutations...
• 14-07-30. 50385 - The 3n + 1 problem
• 14-07-50. 50367 - Bar Codes
• 2013-03-10. 50579 - Pentagonal Nu...
• 2013-03-20. 50589 - The Number of...
• 2013-03-30. 50559 - Prime Factors ...
• 2013-03-40. 50685 - Guest Room U...
• 2013-04-10. 50335 - Five Math Ope...
• 2013-04-100. 50323 - Filtering Cont...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

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

 

Äëÿ îòïðàâêè ðåøåíèé íåîáõîäèìî âûïîëíèòü âõîä.

www.contester.ru