Rezultati

Up. imeNalogaJezikRezultatČas oddaje
zerodays-2017 Jungle Speed Python 3 100/100OK 11. maj '17 @ 17:33

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

Ocenjevani program (speed.py):
n = int(input())
igralci = [[] for i in range(n)]
pred_igralci = [[] for i in range(n)]
karte = list(reversed([int(i) for i in input().split()]))
c = 0
while len(karte) > 0:
    igralci[c%n].append(karte.pop())
    c += 1
    
c = 0
while True:
    if len(igralci[c%n]) == 0:
        igralci[c%n] = pred_igralci[c%n][::-1]
        pred_igralci[c%n] = []
        
        
    pred_igralci[c%n].append(igralci[c%n].pop())
    
    je_pobrou = False
    
    for neki in range(n):
        karta1 = -100
        if len(pred_igralci[neki]) > 0: karta1 = pred_igralci[neki][-1]
        
        karta2 = -101
        if len(pred_igralci[c%n]) > 0: karta2 = pred_igralci[c%n][-1]
        
        if neki != c%n and karta1 == karta2:
            temp = pred_igralci[neki] + pred_igralci[c%n]
            igralci[c%n] = temp[::-1] + igralci[c%n]
            pred_igralci[neki] = []
            pred_igralci[c%n] = []
            je_pobrou = True
            break
    for neki in range(n):
        if len(igralci[neki]) == 0 and len(pred_igralci[neki]) == 0:
            print(neki+1)
            exit()
    if not je_pobrou: c += 1