Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 8,453 MiB 0,000 s OK
#2 10/10 8,527 MiB 0,000 s OK
#3 10/10 8,598 MiB 0,000 s OK
#4 10/10 8,477 MiB 0,000 s OK
#5 10/10 8,539 MiB 0,000 s OK
#6 10/10 8,551 MiB 0,000 s OK
#7 10/10 8,977 MiB 0,000 s OK
#8 10/10 9,008 MiB 0,000 s OK
#9 10/10 8,980 MiB 0,000 s OK
#10 10/10 9,113 MiB 0,000 s OK

Ocenjevani program (main.py):
import sys, math
sys.setrecursionlimit(10**9)


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

inp = sys.stdin

N = int(inp.readline())

data = [[None for j in range(N)] for j in range(N)]

nums = []
for j in range(N**2):
    nums.append(int(inp.readline()))

nums.sort(reverse=True)

#print(nums)

srednji = N//2
x,y = srednji,srednji
i = 0
data[x][y] =  nums[i]
i += 1
x-=1
for j in range(1,N+1):
    for k in range(j):
        x += 1
        y += 1
        #print(x, y)
        if N > x >= 0 and N > y >= 0:
            if data[x][y] is None:
                data[x][y] = nums[i]
                i+=1
    for k in range(j):
        x += 1
        y -= 1
        if N > x >= 0 and N > y >= 0:
            if data[x][y] is None:
                data[x][y] = nums[i]
                i+=1
    for k in range(j):
        x -= 1
        y -= 1
        if N > x >= 0 and N > y >= 0:
            if data[x][y] is None:
                data[x][y] = nums[i]
                i+=1
    for k in range(j):
        x -= 1
        y += 1
        if N > x >= 0 and N > y >= 0:
            if data[x][y] is None:
                data[x][y] = nums[i]
                i+=1
    x -= 1
    #print("konec",x,y)

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