Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 13,727 MiB 0,000 s OK
#2 [več] 20/20 14,043 MiB 0,000 s OK
#3 [več] 20/20 14,043 MiB 0,000 s OK
#4 [več] 20/20 14,043 MiB 0,000 s OK
#5 [več] 20/20 13,824 MiB 0,000 s OK

Ocenjevani program (Malica.cpp):
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <algorithm>
#include <iomanip>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define ford(i,n) for(int i=(int)n-1;i>=0;--i)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


void PP(vvi &vect, string s, int N) {
	for (int i = 0; i < N; i++)
	{
		if (i != 0) {
			for (int b = 0; b < 4; b++)
			{
				vect[i][b] = vect[i - 1][b];
			}
		}
			
		char c = s[i];
		if (c == 'A') {
			vect[i][0]++;
		}
		else if (c == 'C') {
			vect[i][1]++;
		}
		else if (c == 'G') {
			vect[i][2]++;
		}
		else {
			vect[i][3]++;
		}
	}
}

int main()
{
	int B, D, Q, b1, b2, d1, d2, A, C, G, T, ret;
	string bs, ds;
	cin >> B >> D >> Q >> bs >> ds;
	vvi vectB(100000, vi(4, 0)), vectD(100000, vi(4, 0));

	PP(vectB, bs, B);

	PP(vectD, ds, D);
	

	while (Q--) {
		cin >> b1 >> b2 >> d1 >> d2;
		b1--;
		b2--; 
		d1--; 
		d2--;

		int AB = 0, AD = 0, CB = 0, CD = 0, GB = 0, GD = 0, TB = 0, TD = 0;

		if (b1 != 0) {
			AB -= vectB[b1 - 1][0];
			CB -= vectB[b1 - 1][1];
			GB -= vectB[b1 - 1][2];
			TB -= vectB[b1 - 1][3];
		}
		
		AB += vectB[b2][0];
		CB += vectB[b2][1];
		GB += vectB[b2][2];
		TB += vectB[b2][3];
		

		if (d1 != 0) {
			AD -= vectD[d1 - 1][0];
			CD -= vectD[d1 - 1][1];
			GD -= vectD[d1 - 1][2];
			TD -= vectD[d1 - 1][3];
		}

		AD += vectD[d2][0];
		CD += vectD[d2][1];
		GD += vectD[d2][2];
		TD += vectD[d2][3];

		A = abs(AB - AD);
		C = abs(CB - CD);
		G = abs(GB - GD);
		T = abs(TB - TD);


		ret = A + C + G + T;

		cout << ret << "\n";
	}

	return 0;
}