Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ocetje-interneta-2019 Biodiverziteta Python 3 100/100OK 09. maj '19 @ 18:22

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 23,344 MiB 1,916 s OK
#2 [več] 20/20 37,113 MiB 2,445 s OK
#3 [več] 20/20 37,074 MiB 2,501 s OK
#4 [več] 20/20 37,113 MiB 2,485 s OK
#5 [več] 20/20 37,266 MiB 2,485 s OK

Ocenjevani program (c.py):
n,m,q=map(int,input().split())
a=input()
b=input()

def psum(a, b, arr):
    return [
       arr[b][0] - arr[a-1][0],
       arr[b][1] - arr[a-1][1],
       arr[b][2] - arr[a-1][2],
       arr[b][3] - arr[a-1][3],
    ]

# A C G T
acgt = [0,0,0,0]
asum = [acgt.copy()]
for i in range(n):
    if (a[i] == 'A'): acgt[0]+=1
    if (a[i] == 'C'): acgt[1]+=1
    if (a[i] == 'G'): acgt[2]+=1
    if (a[i] == 'T'): acgt[3]+=1
    
    asum.append(acgt.copy())

acgt = [0,0,0,0]
bsum = [acgt.copy()]
for i in range(m):
    if (b[i] == 'A'): acgt[0]+=1
    if (b[i] == 'C'): acgt[1]+=1
    if (b[i] == 'G'): acgt[2]+=1
    if (b[i] == 'T'): acgt[3]+=1
    bsum.append(acgt.copy())

for i in range(q):
    s,t,u,v = map(int,input().split())
    first = psum(s, t, asum)
    second = psum(u, v, bsum)
    print(abs(first[0]-second[0])+abs(first[1]-second[1])+abs(first[2]-second[2])+abs(first[3]-second[3]))