ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1082. Gaby Ivanushka

Because the procedure P is sorting .
The tsar's program is quicksort algorithm
it sorts input array and counts in how many swaps it was done (variable c)(not exact value but represents it)...
Just try to think about variable c and you will realize that.
So the solution is to print not only 1,2,...,n but
ANY SORTED ARRAY OF LENGTH N
I resolve it by recursively fill the whole array.

And I think out sorted array because I think it is easier to make the array sorted(since then the quicksort become bubble sort).