Rezultati

Up. imeNalogaJezikRezultatČas oddaje
zerodays-2018 Birokrati Python 3 100/100OK 04. okt '18 @ 19:42

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 8,352 MiB 0,000 s OK
#2 9/9 8,445 MiB 0,000 s OK
#3 9/9 8,410 MiB 0,000 s OK
#4 9/9 8,340 MiB 0,000 s OK
#5 9/9 8,359 MiB 0,000 s OK
#6 9/9 8,566 MiB 0,000 s OK
#7 9/9 8,906 MiB 0,000 s OK
#8 9/9 10,102 MiB 0,000 s OK
#9 9/9 9,879 MiB 0,000 s OK
#10 9/9 16,188 MiB 0,000 s OK
#11 10/10 8,441 MiB 0,000 s OK

Ocenjevani program (birokrati2.py):
class Hlod:
    def __init__(self, ime):
        self.ime = ime
        self.veje = []

folk = []
while True:
    try:
        clovek, obtozi = input().split()
        clovek = clovek[1:].split('/')
        folk.append((clovek, obtozi))
    except:
        break

hlod = Hlod('/')
zacetek = None
folk.sort()

folkd = {}
nivoji_clouk = {}
for c in folk:
    trenutn_hlod = hlod
    temp = ''
    sam_enke = True

    for i in range(len(c[0]) - 1):
        if len(temp) != 0:
            temp += '.'
        
        tekst = c[0][i]
        imena_vej = [veja.ime for veja in trenutn_hlod.veje]
        if tekst in imena_vej:
            cifra = imena_vej.index(tekst)
            trenutn_hlod = trenutn_hlod.veje[cifra]
        else:
            cifra = len(trenutn_hlod.veje)
            trenutn_hlod.veje.append(
                Hlod(tekst)
            )
            trenutn_hlod = trenutn_hlod.veje[-1]

        if cifra != 0:
            sam_enke = False

        temp += str(cifra + 1)

    # se za folk
    if len(temp) != 0:
        temp += '.'
    
    nivo = nivoji_clouk.get(temp, None)
    if nivo is None:
        nivoji_clouk[temp] = 1
        nivo = 1
    else:
        sam_enke = False

    nivoji_clouk[temp] += 1
    temp += str(nivo)
        
    folkd[temp] = (temp, c[0], c[1])

    if sam_enke:
        if zacetek is None:
            zacetek = temp
        else:
            zacetek = sorted([zacetek, temp], key=len)[0]

# print()
# print()
# print()
# print()
# for k in folkd.keys():
#     print(k, folkd[k])
# exit()

seen = set()
trenuten = zacetek

for _ in range(len(folk)):
    temp, ime, obtozi = folkd[trenuten]

    if obtozi not in folkd.keys() or obtozi in seen:
        print('/' + '/'.join(ime))
        break

    seen.add(temp)
    trenuten = obtozi