Rezultati

Up. imeNalogaJezikRezultatČas oddaje
JayZCrew Pasavci Python 3 0/100Prekoračen čas (TLE) 11. maj '17 @ 19:34

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 8,625 MiB 0,000 s OK
#2 5/5 8,648 MiB 0,000 s OK
#3 5/5 8,645 MiB 0,000 s OK
#4 5/5 8,684 MiB 0,000 s OK
#5 5/5 8,727 MiB 0,000 s OK
#6 5/5 8,824 MiB 0,000 s OK
#7 5/5 8,820 MiB 0,000 s OK
#8 5/5 8,844 MiB 0,000 s OK
#9 6/6 8,816 MiB 0,000 s OK
#10 0/6 10,063 MiB 2,038 s Prekoračen čas
#11 6/6 8,625 MiB 0,000 s OK
#12 6/6 8,617 MiB 0,000 s OK
#13 6/6 8,621 MiB 0,000 s OK
#14 6/6 8,602 MiB 0,000 s OK
#15 6/6 8,633 MiB 0,000 s OK
#16 6/6 8,582 MiB 0,000 s OK
#17 6/6 8,602 MiB 0,000 s OK
#18 0/6 10,102 MiB 2,007 s Prekoračen čas

Ocenjevani program (pasa.py):
p =  input().strip()
P = len(p)
s1  = input().strip()
s2 = input().strip()
m = int(input().strip())

MOD = 10**9 + 7

slovar = dict()

def pojavitve(niz):
    global P, p
    cnt = 0
    for i in range(len(niz) - P):
        if niz[i:i+P] == p:
            cnt += 1
    return cnt

slovar[0] = [s1[:P-1], s1[-P:], pojavitve(s1)]
slovar[1] = [s2[:P-1], s2[-P:], pojavitve(s2)]

for K in range(m):
    X = input().strip().split()
    a,b = map(int, X)
    a, b = a -1, b - 1
    ZAC = (slovar[a][0] + slovar[b][0])[:P-1]
    KON = (slovar[a][1] + slovar[b][1])[-P:]
    COUNT = (slovar[a][2] + slovar[b][2]) % MOD
    for V in range(1, P):
        niz = slovar[a][1][-V:] + slovar[b][0][:P-V]
        if niz == p:
            COUNT += 1
    slovar[K+2] = [ZAC,KON, COUNT % MOD]
print(slovar[m+1][2] % MOD)