Rezultati

Up. imeNalogaJezikRezultatČas oddaje
Kumkvat Jungle Speed Python 3 100/100OK 11. maj '17 @ 18:37

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 8,613 MiB 0,000 s OK
#2 9/9 8,602 MiB 0,000 s OK
#3 9/9 8,621 MiB 0,000 s OK
#4 9/9 8,605 MiB 0,000 s OK
#5 9/9 8,633 MiB 0,000 s OK
#6 9/9 8,609 MiB 0,000 s OK
#7 9/9 8,621 MiB 0,000 s OK
#8 9/9 8,609 MiB 0,000 s OK
#9 9/9 8,617 MiB 0,000 s OK
#10 9/9 8,605 MiB 0,000 s OK
#11 10/10 8,625 MiB 0,000 s OK

Ocenjevani program (jungle.py):
n = input()
n = int(n)
karte = input()
karte = list(map(int, karte.split()))
stevilo = len(karte)
vsak = stevilo // n

roke = [[] for i in range(n)]
miza = [[] for i in range(n)]

for i in range(stevilo):
    j = i % n
    roke[j] = roke[j] + [karte[i]]


def je_konec(roke, karte, n):
    for i in range(n):
        if (len(roke[i]) == 0) and (len(miza[i]) == 0):
            return i + 1
    return False

def enaki(miza, n):
    for i in range(n):
        for j in range(i+1, n):
            if miza[i] != [] and miza[j] != []:
                if miza[i][-1] == miza[j][-1]:
                    return (i, j)
    return None

konec = je_konec(roke, karte, n)
i = 0
while not konec:
    j = i % n
    if roke[j] == []:
        roke[j] = miza[j]
        miza[j] = []
    miza[j] += [roke[j][-1]]
    roke[j] = roke[j][:len(roke[j])-1]
    e = enaki(miza, n)
    if e is not None:
        (prvi, drugi) = e
        if j == prvi:
            roke[j] = list(reversed(miza[j])) + list(reversed(miza[drugi])) + roke[j]
        else:
            roke[j] = list(reversed(miza[j])) + list(reversed(miza[prvi])) + roke[j]
        miza[prvi] = []
        miza[drugi] = []
    if e is None:
        i += 1

    konec = je_konec(roke, karte, n)


print(konec)