Rezultati

Up. imeNalogaJezikRezultatČas oddaje
zerodays-2018 Kvadrat števil Python 3 100/100OK 13. okt '18 @ 12:03

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 8,676 MiB 0,000 s OK
#2 10/10 8,539 MiB 0,000 s OK
#3 10/10 8,672 MiB 0,000 s OK
#4 10/10 8,523 MiB 0,000 s OK
#5 10/10 8,664 MiB 0,000 s OK
#6 10/10 8,547 MiB 0,000 s OK
#7 10/10 8,918 MiB 0,000 s OK
#8 10/10 8,949 MiB 0,000 s OK
#9 10/10 8,930 MiB 0,000 s OK
#10 10/10 8,984 MiB 0,000 s OK

Ocenjevani program (kvadrat.py):
def nastavi(x, y):
    global center
    global cifre
    global i
    global resitev
    
    cifra = cifre[i]
    i += 1
    resitev[x + center][y + center] = cifra

n = int(input())

cifre = []

for _ in range(n**2):
    cifre.append(int(input()))

cifre.sort(reverse=True)

resitev = [[None for _ in range(n)] for __ in range(n)]

center = n // 2
i = 0

nastavi(0, 0)

for offset in range(1, center + 1):
    # gor
    nastavi(0, offset)
    # dol
    nastavi(0, -offset)
    # levo
    nastavi(-offset, 0)
    # desno
    nastavi(offset, 0)

    for offset_2 in range(1, offset + 1):
        # gor levo
        nastavi(-offset_2, offset)
        # gor desno
        nastavi(offset_2, offset)
        
        # dol levo
        nastavi(-offset_2, -offset)
        # dol desno
        nastavi(offset_2, -offset)

        if offset_2 == offset:
            continue

        # desno dol
        nastavi(offset, -offset_2)
        # desno gor
        nastavi(offset, offset_2)

        # levo dol
        nastavi(-offset, -offset_2)
        # levo gor
        nastavi(-offset, offset_2)


for i in range(n):
    print(' '.join(map(str, resitev[i])))