Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 33,066 MiB 2,569 s OK
#2 [več] 20/20 56,516 MiB 3,411 s OK
#3 [več] 20/20 56,441 MiB 3,025 s OK
#4 [več] 20/20 56,496 MiB 3,147 s OK
#5 [več] 20/20 56,441 MiB 3,129 s OK

Ocenjevani program (bio.py):
n, m, q = map(int, input().split())
A = list(input())
B = list(input())

na = [[0, 0, 0, 0] for i in range(n+1)]
nb = [[0, 0, 0, 0] for i in range(m+1)]

# a poracunamo
for i in range(n):
    a, c, g, t = 0, 0, 0, 0
    if A[i] == 'A':
        a = 1
    elif A[i] == 'C':
        c = 1
    elif A[i] == 'G':
        g = 1
    elif A[i] == 'T':
        t = 1

    na[i+1] =  [na[i][0] + a, na[i][1] + c, na[i][2] + g, na[i][3] + t]

# b poracunamo

for i in range(m):
    a, c, g, t = 0, 0, 0, 0
    if B[i] == 'A':
        a = 1
    elif B[i] == 'C':
        c = 1
    elif B[i] == 'G':
        g = 1
    elif B[i] == 'T':
        t = 1

    nb[i+1] =  [nb[i][0] + a, nb[i][1] + c, nb[i][2] + g, nb[i][3] + t]

def r(prvi, drugi):
    res = 0
    for i in range(len(prvi)):
        res += abs(prvi[i] - drugi[i])
    return res

for i in range(q):
    si, ti, ui, vi = map(lambda x: int(x) -1, input().split())

    mama_a = [na[ti+1][0] - na[si][0], na[ti+1][1] - na[si][1], na[ti+1][2] - na[si][2], na[ti+1][3] - na[si][3]]
    mama_b = [nb[vi+1][0] - nb[ui][0], nb[vi+1][1] - nb[ui][1], nb[vi+1][2] - nb[ui][2], nb[vi+1][3] - nb[ui][3]]
    print(r(mama_a, mama_b))