█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 1541

Problema 0xde - Ordenar un arreglo grande

  • Autor: Serivt
  • Fecha: 2020-11-03 03:59:26 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#2
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#3
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#4
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#5
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#6
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#7
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#8
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#9
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#10
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#11
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#12
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#13
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#14
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#15
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#16
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#17
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#18
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#19
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#20
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#21
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#22
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#23
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#24
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#25
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#26
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
#27
Error de compilación
                      main.c:1:3: error: invalid preprocessing directive
# https://www.geeksforgeeks.org/quick-sort/?ref=lbp
  ^
main.c:3:1: error: unknown type name 'def'
def partition(arr, low, high):
^
main.c:3:30: error: expected function body after function declarator
def partition(arr, low, high):
                             ^
3 errors generated.

                    
Puntos totales: 0 / 100

Código

# https://www.geeksforgeeks.org/quick-sort/?ref=lbp

def partition(arr, low, high):
    i = low - 1
    pivot = arr[high]
    for j in range(low, high):
        if arr[j] <= pivot:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[high] = arr[high], arr[i + 1]
    return i + 1


def _quicksort(arr, low, high):
    if len(arr) == 1:
        return arr
    if low < high:
        pivot = partition(arr, low, high)
        _quicksort(arr, low, pivot - 1)
        _quicksort(arr, pivot + 1, high)

def quicksort(arr):
    _quicksort(arr, 0, len(arr) - 1)

if __name__ == "__main__":
    n = input()
    arr = list(map(int, input().split(" ")))
    quicksort(arr)
    print(" ".join(map(str, arr)))