Rezultati

Up. imeNalogaJezikRezultatČas oddaje
gosenice-2019 Biodiverziteta Python 3 100/100OK 09. maj '19 @ 17:17

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 14,805 MiB 1,610 s OK
#2 [več] 20/20 21,035 MiB 2,056 s OK
#3 [več] 20/20 21,035 MiB 1,650 s OK
#4 [več] 20/20 20,887 MiB 1,523 s OK
#5 [več] 20/20 20,887 MiB 1,711 s OK

Ocenjevani program (biodiverziteta.py):
import math

def count(niz, n, nizA, nizC, nizG, nizT):
    a = 0
    c = 0
    g = 0
    t = 0
    for i in range(0, n):
        if niz[i] == 'A':
            a += 1
        elif niz[i] == 'C':
            c += 1
        elif niz[i] == 'G':
            g += 1
        else:
            t += 1
        nizA[i+1] = a
        nizC[i+1] = c
        nizG[i+1] = g
        nizT[i+1] = t



def razlika(a1, a2, c1, c2, g1, g2, t1, t2):
    return abs(a1 - a2) + abs(c1 - c2) + abs(g1 - g2) + abs(t1 - t2)

n, m, q = map(int,input().split())
niz1 = input()
niz2 = input()
A1 = [0 for i in range(n+1)]
C1 = [0 for i in range(n+1)]
G1 = [0 for i in range(n+1)]
T1 = [0 for i in range(n+1)]
A2 = [0 for i in range(m+1)]
C2 = [0 for i in range(m+1)]
G2 = [0 for i in range(m+1)]
T2 = [0 for i in range(m+1)]

count(niz1, n, A1, C1, G1, T1)
count(niz2, m, A2, C2, G2, T2)


for i in range(0,q):
    x1,y1,x2,y2 = map(int,input().split())
    a1 = A1[y1] - A1[x1 - 1]
    c1 = C1[y1] - C1[x1 - 1]
    g1 = G1[y1] - G1[x1 - 1]
    t1 = T1[y1] - T1[x1 - 1]
    a2 = A2[y2] - A2[x2 - 1]
    c2 = C2[y2] - C2[x2 - 1]
    g2 = G2[y2] - G2[x2 - 1]
    t2 = T2[y2] - T2[x2 - 1]
    print(razlika(a1, a2, c1, c2, g1, g2, t1, t2))