Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 22,680 MiB 1,105 s OK
#2 [več] 20/20 28,844 MiB 1,545 s OK
#3 [več] 20/20 29,102 MiB 1,272 s OK
#4 [več] 20/20 28,711 MiB 1,504 s OK
#5 [več] 20/20 28,785 MiB 1,606 s OK

Ocenjevani program (biodiv.py):
import sys
data = sys.stdin.readlines()
#data = open("/home/putka-kjejenovictk-2019/Desktop/biodivTest").readlines()

n = data[1].strip()
m = data[2].strip()

Nn = len(n)
Nm = len(m)

dolzina = max(Nn, Nm)

an = [0]
am = [0]
cn = [0]
cm = [0]
gn = [0]
gm = [0]
tn = [0]
tm = [0]

for i in range(0,dolzina):
    if i < Nn:
        if n[i] == "A":
           an.append(an[i] + 1)
        else:
            an.append(an[i])
        if n[i] == "C":
            cn.append(cn[i] + 1)
        else:
            cn.append(cn[i])
        if n[i] == "G":
            gn.append(gn[i] + 1)
        else:
            gn.append(gn[i])
        if n[i] == "T":
            tn.append(tn[i] + 1)
        else:
            tn.append(tn[i])

    if i < Nm:
        if m[i] == "A":
           am.append(am[i] + 1)
        else:
            am.append(am[i])
        if m[i] == "C":
            cm.append(cm[i] + 1)
        else:
            cm.append(cm[i])
        if m[i] == "G":
            gm.append(gm[i] + 1)
        else:
            gm.append(gm[i])
        if m[i] == "T":
            tm.append(tm[i] + 1)
        else:
            tm.append(tm[i])

data = data[3:]

for line in data:
    sn, kn, sm, km = list(map(int, line.strip().split()))
    print(
          abs(an[kn] - an[sn-1] - am[km] + am[sm-1])
        + abs(cn[kn] - cn[sn-1] - cm[km] + cm[sm-1])
        + abs(gn[kn] - gn[sn-1] - gm[km] + gm[sm-1])
        + abs(tn[kn] - tn[sn-1] - tm[km] + tm[sm-1])
    )