Rezultati

Up. imeNalogaJezikRezultatČas oddaje
final-solution-2019 Biodiverziteta C++ 100/100OK 09. maj '19 @ 16:46

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 7,328 MiB 0,104 s OK
#2 [več] 20/20 8,473 MiB 0,168 s OK
#3 [več] 20/20 8,473 MiB 0,140 s OK
#4 [več] 20/20 8,496 MiB 0,149 s OK
#5 [več] 20/20 8,496 MiB 0,162 s OK

Ocenjevani program (Biodiverziteta.cpp):
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define maxn 200111
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

char a[maxn], b[maxn];
int pa[4][maxn], pb[4][maxn];
int n, m, q;

void preprocess(){
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 4; j++)
            pa[j][i] += pa[j][i - 1];

        if(a[i] == 'A')
            pa[0][i]++;

        if(a[i] == 'C')
            pa[1][i]++;

        if(a[i] == 'G')
            pa[2][i]++;

        if(a[i] == 'T')
            pa[3][i]++;
    }

    for(int i = 1; i <= m; i++){
        for(int j = 0; j < 4; j++)
            pb[j][i] += pb[j][i - 1];

        if(b[i] == 'A')
            pb[0][i]++;

        if(b[i] == 'C')
            pb[1][i]++;

        if(b[i] == 'G')
            pb[2][i]++;

        if(b[i] == 'T')
            pb[3][i]++;
    }
}

int solve(int la, int da, int lb, int db){
    int ret = 0;

    for(int i = 0; i < 4; i++)
        ret += abs((pa[i][da] - pa[i][la - 1]) - (pb[i][db] - pb[i][lb - 1]));
    
    return ret;
}

int main(){
  
    scanf("%d%d%d", &n, &m, &q);
    scanf("%s", a + 1);
    scanf("%s", b + 1);
    preprocess();

    while(q--){
        int la, da, lb, db;
        scanf("%d%d%d%d", &la, &da, &lb, &db);
        printf("%d\n", solve(la, da, lb, db));
    }

    return 0;
}