Rezultati

Up. imeNalogaJezikRezultatČas oddaje
vlakec-tomaz-in-ekipa-raketa-2019 Biodiverziteta Python 3 100/100OK 09. maj '19 @ 16:53

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 14,785 MiB 2,737 s OK
#2 [več] 20/20 20,953 MiB 3,230 s OK
#3 [več] 20/20 20,820 MiB 3,209 s OK
#4 [več] 20/20 20,816 MiB 3,326 s OK
#5 [več] 20/20 20,965 MiB 3,393 s OK

Ocenjevani program (biodiverziteta.py):
n,m,q = map(int, input().split(" "))

keys = ["A", "C", "T", "G"]
s1 = input().strip()
s2 = input().strip()

def zeros(l):
    return [0 for _ in range(l+1)]


cur1 = {"A":0,"C":0,"G":0,"T":0}
cur2 = {"A":0,"C":0,"G":0,"T":0}
vsote1 = {"A":zeros(n),"C":zeros(n),"G":zeros(n),"T":zeros(n)}
vsote2 = {"A":zeros(m),"C":zeros(m),"G":zeros(m),"T":zeros(m)}

for i,c in enumerate(s1):
    for k in keys:
        if c==k:
            cur1[k] += 1
        vsote1[k][i+1] = cur1[k]

for i,c in enumerate(s2):
    for k in keys:
        if c==k:
            cur2[k] += 1
        vsote2[k][i+1] = cur2[k]

for i in range(q):
    s1,e1,s2,e2 = map(int, input().split(" "))

    c1 = {k:vsote1[k][e1]-vsote1[k][s1-1] for k in keys}
    c2 = {k:vsote2[k][e2]-vsote2[k][s2-1] for k in keys}

    res = sum((abs(c1[k]-c2[k]) for k in keys))
    print(res)