Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 25,961 MiB 0,000 s OK
#2 [več] 20/20 47,852 MiB 0,000 s OK
#3 [več] 20/20 47,852 MiB 0,000 s OK
#4 [več] 20/20 47,695 MiB 0,000 s OK
#5 [več] 20/20 47,848 MiB 0,000 s OK

Ocenjevani program (bio2.cpp):
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;
vector<map<char, int>> freqB;
vector<map<char, int>> freqD;

int main() {
	int N, M, q, s, t, u, w;
	long long int razlika;
	string B, D;
	cin >> N >> M >> q;
	cin.get();
	getline(cin, B);
	getline(cin, D);
	freqB.resize(N + 1);
	freqD.resize(M + 1);

	freqB[0]['A'] = 0; freqB[0]['C'] = 0; freqB[0]['T'] = 0; freqB[0]['G'] = 0;
	for (int i = 0; i < N; i++) {
		freqB[i + 1]['A'] = freqB[i]['A'];
		freqB[i + 1]['C'] = freqB[i]['C'];
		freqB[i + 1]['G'] = freqB[i]['G'];
		freqB[i + 1]['T'] = freqB[i]['T'];
		freqB[i + 1][B[i]]++;
	}

	freqD[0]['A'] = 0; freqD[0]['C'] = 0; freqD[0]['T'] = 0; freqD[0]['G'] = 0;
	for (int i = 0; i < M; i++) {
		freqD[i + 1]['A'] = freqD[i]['A'];
		freqD[i + 1]['C'] = freqD[i]['C'];
		freqD[i + 1]['G'] = freqD[i]['G'];
		freqD[i + 1]['T'] = freqD[i]['T'];
		freqD[i + 1][D[i]]++;
	}

	while (q--) {
		cin >> s >> t >> u >> w;
		razlika = abs(freqB[t]['A'] - freqB[s - 1]['A'] - (freqD[w]['A'] - freqD[u - 1]['A'])) +
			abs(freqB[t]['C'] - freqB[s - 1]['C'] - (freqD[w]['C'] - freqD[u - 1]['C'])) +
			abs(freqB[t]['G'] - freqB[s - 1]['G'] - (freqD[w]['G'] - freqD[u - 1]['G'])) +
			abs(freqB[t]['T'] - freqB[s - 1]['T'] - (freqD[w]['T'] - freqD[u - 1]['T']));
		cout << razlika << endl;
	}

	//system("pause");
	return 0;
}