Rezultati

Up. imeNalogaJezikRezultatČas oddaje
jayzcrew-2018 Kvadrat števil Python 3 100/100OK 13. okt '18 @ 11:44

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 8,668 MiB 0,000 s OK
#2 10/10 8,691 MiB 0,000 s OK
#3 10/10 8,590 MiB 0,000 s OK
#4 10/10 8,676 MiB 0,000 s OK
#5 10/10 8,605 MiB 0,000 s OK
#6 10/10 8,695 MiB 0,000 s OK
#7 10/10 8,965 MiB 0,000 s OK
#8 10/10 8,957 MiB 0,000 s OK
#9 10/10 8,977 MiB 0,000 s OK
#10 10/10 9,043 MiB 0,000 s OK

Ocenjevani program (4.py):
import sys

#sys.stdin = open("1.in")

n = int(sys.stdin.readline().strip())

def order_line(s):
    l = len(s)
    ordered = [None for _ in range(l)]
    #s.sort()
    middle = l//2
    i = 1
    ordered[middle] = s[-1]
    s.pop()
    while s:
        ordered[middle + i] = s[-1]
        s.pop()
        ordered[middle - i] = s[-1]
        s.pop()
        i +=1
    return ordered

def order_cols(s):
    l = len(s)
    ordered = [[] for _ in range(l)]
    #s.sort()
    middle = l // 2
    i = 1
    ordered[middle] = s[-1]
    s.pop()
    while s:
        ordered[middle + i] = s[-1]
        s.pop()
        ordered[middle - i] = s[-1]
        s.pop()
        i += 1
    return ordered



sez = []
for _ in range(n**2):
    sez.append(int(sys.stdin.readline().strip()))


sez.sort()

matrix = []
for i in range(n):
    tmp = []
    for j in range(n):
        tmp.append(sez[n*i + j])
    matrix.append(tmp)

for i in range(len(matrix)):
    matrix[i] = order_line(matrix[i][:])



for i in order_cols(matrix):
    print(" ".join(map(str, i)))