Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 9,027 MiB 0,000 s OK
#2 9/9 9,082 MiB 0,000 s OK
#3 9/9 9,098 MiB 0,000 s OK
#4 9/9 9,043 MiB 0,000 s OK
#5 9/9 9,051 MiB 0,000 s OK
#6 9/9 9,109 MiB 0,000 s OK
#7 9/9 9,102 MiB 0,000 s OK
#8 9/9 9,043 MiB 0,000 s OK
#9 9/9 9,059 MiB 0,000 s OK
#10 9/9 9,023 MiB 0,000 s OK
#11 10/10 9,059 MiB 0,000 s OK

Ocenjevani program (jungle.py):
import sys
from collections import deque

inp = sys.stdin
#inp = open("a.in", "r")

n = int(inp.readline().strip())
data = list(map(int, inp.readline().split()))
roka = [deque() for i in range(n)]
miza = [deque() for i in range(n)]
current = 0
for d in data:
    roka[current].append(d)
    current += 1
    current %= n

tr = 0
try:
    while 1:
        if not roka[tr]:
            roka[tr] = deque(reversed(miza[tr]))
            miza[tr] = deque()
        karta = roka[tr].pop()
        miza[tr].append(karta)
        nex = True
        for i in range(len(miza)):
            kup = miza[i]
            if i != tr and len(kup) > 0 and kup[-1] == karta:
                nex = False
                neki = list((miza[i] + miza[tr]))
                roka[tr].extendleft(neki)
                miza[i] = deque()
                miza[tr] = deque()
                if not roka[i]:
                    print(i+1)
                    1/0
        if nex:
            tr += 1
            tr = (tr %n)
except ZeroDivisionError:
    pass