DMPG '17 B4 - Bad Sort

View as PDF

Submit solution

Points: 7
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type

Roger is teaching his CS club how to sort! This algorithm looks like this:

function sort(A[0 .. N - 1]):
    if A is not empty:
        pivot <- A[N/2]
        lesser <- []
        equal <- []
        greater <- []
        for each a in A:
            if a < pivot:
                append a to lesser
            if a = pivot:
                append a to equal
            if a > pivot:
                append a to greater
        sort(lesser)
        sort(greater)
        A <- lesser + equal + greater

However, you think that Roger is inferior to Kirito, and that his sort has a devastating flaw! Can you generate a worst case?

Input Specification

There is no input.

Output Specification

Print 1\,024 integers, each on a newline, representing a worst-case scenario for the sorting algorithm.


Comments


  • 15
    kipply  commented on May 22, 2017, 6:02 p.m.

    This is funny because Roger is Kirito