Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 4,703 MiB 0,000 s OK
#2 [več] 20/20 6,293 MiB 0,000 s OK
#3 [več] 20/20 6,133 MiB 0,000 s OK
#4 [več] 20/20 6,289 MiB 0,000 s OK
#5 [več] 20/20 6,297 MiB 0,000 s OK

Ocenjevani program (bio.cpp):
#include<iostream>
#include<cmath>
using namespace std;

int main(){
	int n, m, q;
	cin>>n>>m>>q;
	
	string s1, s2;
	cin>>s1>>s2;
	int ps1[n+1][4]; 
	int ps2[m+1][4]; 
	
	for (int i = 0; i < 4; i++){
		ps1[0][i] = 0;
		ps2[0][i] = 0;
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 4; j++){
			ps1[i+1][j] = ps1[i][j];
		}
		
		if (s1[i] == 'A') ps1[i+1][0]++;
		else if (s1[i] == 'C') ps1[i+1][1]++;
		else if (s1[i] == 'G') ps1[i+1][2]++;
		else if (s1[i] == 'T') ps1[i+1][3]++;
	}
	/*
	for (int i = 0; i < n + 1; i++){
		for (int j = 0; j < 4; j++){
			cout<<ps1[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	
	for (int i = 0; i < m; i++){
		for (int j = 0; j < 4; j++){
			ps2[i+1][j] = ps2[i][j];
		}
		
		if (s2[i] == 'A') ps2[i+1][0]++;
		else if (s2[i] == 'C') ps2[i+1][1]++;
		else if (s2[i] == 'G') ps2[i+1][2]++;
		else if (s2[i] == 'T') ps2[i+1][3]++;
	}
	
	int s, t, u, v, res;
	for (int i = 0; i < q; i++){
		cin>>s>>t>>u>>v;
		res = 0;
		
		for (int j = 0; j < 4; j++){
			res += abs(ps1[t][j] - ps1[s - 1][j] - (ps2[v][j] - ps2[u - 1][j]));
		}
		cout<<res<<endl;
	}
}