Rezultati

Up. imeNalogaJezikRezultatČas oddaje
trivialca-2019 Biodiverziteta C++ 100/100OK 09. maj '19 @ 19:38

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 4,707 MiB 0,000 s OK
#2 [več] 20/20 6,301 MiB 0,000 s OK
#3 [več] 20/20 6,145 MiB 0,000 s OK
#4 [več] 20/20 6,297 MiB 0,000 s OK
#5 [več] 20/20 6,148 MiB 0,000 s OK

Ocenjevani program (nal2.cpp):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
//printf("%.9Ld");

#define maxn 110000

typedef struct{
	int a;
	int c;
	int g;
	int t;
}znaki;

void prestej(znaki &a, char &znak) {
	if(znak == 'A') {
		++a.a;
	} else if(znak == 'C') {
		++a.c;
	}
	 else if(znak == 'G') {
		++a.g;
	}
	 else if(znak == 'T') {
		++a.t;
	}
}

ll bio(znaki &x1, znaki &x2, znaki &y1, znaki &y2) {
	znaki a{x2.a - x1.a, x2.c - x1.c, x2.g - x1.g, x2.t - x1.t};
	znaki b{y2.a - y1.a, y2.c - y1.c, y2.g - y1.g, y2.t - y1.t};
	
	return abs(a.a - b.a) + abs(a.c - b.c) + abs(a.g - b.g) + abs(a.t - b.t);
}

znaki niz1[maxn];
znaki niz2[maxn];

int main() {
	
	int n, m, q;
	string a, b;
	cin >> n >> m >> q;
	cin >> a >> b;
	
	znaki n1{0,0,0,0}, n2{0,0,0,0};
	
	for(int i = 0; i < n; ++i) {
		prestej(n1, a[i]);
		niz1[i + 1] = n1;
	}
	for(int i = 0; i < m; ++i) {
		prestej(n2, b[i]);
		niz2[i + 1] = n2;
		}
		
		//~ niz1[0] = {0,0,0,0};
		//~ niz2[0] = {0,0,0,0};
	
	for(int i = 0; i < q; ++i) {
		int x1,x2,y1,y2;
		cin >> x1 >> x2 >> y1 >> y2;
		cout << bio(niz1[x1 - 1], niz1[x2], niz2[y1 - 1], niz2[y2]) << endl;
	}
	//~ cout << niz1[3-1].a << " "<< niz1[3-1].c << " "<< niz1[3-1].g << " "<< niz1[3-1].t << " "<< endl;
	//~ cout << niz1[7].a << " "<< niz1[7].c << " "<< niz1[7].g << " "<< niz1[7].t << " "<< endl;
	
	//~ cout << niz2[5-1].a << " "<< niz2[5-1].c << " "<< niz2[5-1].g << " "<< niz2[5-1].t << " "<< endl;
	//~ cout << niz2[10].a << " "<< niz2[10].c << " "<< niz2[10].g << " "<< niz2[10].t << " "<< endl;
	//~ for(int i = 0; i < n; ++i) {
		//~ cout << niz1[i].a << " "<< niz1[i].c << " "<< niz1[i].g << " "<< niz1[i].t << " "<< endl;
	//~ }
	//~ cout << "-------\n\n" << endl;
	//~ for(int i = 0; i < m; ++i) {
		//~ cout << niz2[i].a << " "<< niz2[i].c << " "<< niz2[i].g << " "<< niz2[i].t << " "<< endl;
	//~ }
	
	
	

	return 0;
}