Editorial for Wesley's Anger Contest 4 Problem 1 - Zeyu's Zany Zort


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Pookmeister

The most common mistake for this problem was not following the Output Specification as many people faced Presentation Errors.

Some solutions included qsort, bubble sort, insertion sort, built-in sort and sorting then reversing the array.

Notable solutions include:

  • Creating a temporary list of a[l,r], sorting it then reassigning values back to the original array a.
  • Creating a temporary list of a[l,r], sorting it then removing a[l,r] from a, then reinserting the temporary array back into a.

Time Complexity: \mathcal{O}(Q \cdot N^2) if bubble sort is used


Comments

There are no comments at the moment.