Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 8,203 MiB 0,000 s OK
#2 9/9 8,211 MiB 0,000 s OK
#3 9/9 8,207 MiB 0,000 s OK
#4 9/9 8,195 MiB 0,000 s OK
#5 9/9 8,336 MiB 0,000 s OK
#6 9/9 8,434 MiB 0,000 s OK
#7 9/9 9,313 MiB 0,000 s OK
#8 9/9 9,055 MiB 0,000 s OK
#9 9/9 9,102 MiB 0,000 s OK
#10 9/9 9,230 MiB 0,000 s OK
#11 10/10 8,289 MiB 0,000 s OK

Ocenjevani program (birokrati.py):
import sys
import math

sys.setrecursionlimit(10**9)

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

inp = sys.stdin

pari = dict()

osebe = []

for line in inp:
    a,b = line.strip().split(' ')
    pari[a] = b

    osebe.append(a)

nosebe = [e.split('/')[1:] for e in osebe]

tags = dict()

def recursion(idd, predniz, besede):

    people = set()

    oddelki = set()

    noveosebe = list()

    for e in besede:
        if len(e) == 0:
            print(idd, predniz, e)
        if len(e) == 1:
            people.add(e[0])
        else:
            oddelki.add(e[0])

    people = list(people)
    oddelki = list(oddelki)

    people.sort()
    oddelki.sort()


    for i in range(len(people)):
        cifra = i + 1
        newid = idd + str(cifra)
        novniz = predniz + str(people[i])

        tags[novniz] = newid

    for i in range(len(oddelki)):
        cifra = i + 1
        newid = idd + str(cifra) + '.'
        novniz = predniz + oddelki[i] + '/'

        novebesede = []

        for b in besede:
            if len(b) == 1:
                continue
            if b[0] == oddelki[i]:
                novebesede.append(b[1:][:])


        recursion(newid, novniz, novebesede)

recursion('', '/', nosebe)

rev = dict()
for e in tags:
    rev[tags[e]] = e

mini = min(tags.values())

videni = set()

videni.add(mini)
while True:
    if mini in rev:
        sem = rev[mini]
        nekst = pari[sem]
        if nekst in rev:
            if nekst in videni:
                print(sem)
                break
            else:
                videni.add(nekst)
                mini = nekst
        else:
            print(sem)
            break

    else:
        print(rev[mini])
        break