Submission #529191

#TimeUsernameProblemLanguageResultExecution timeMemory
529191Icebear16Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h"
long long n,q;
void init(std::string a, std::string b) {
	while(q--){
    	long long x,y;
		get_distance(x,y);
	}
}
int get_distance(long long x, long long y) {
	long long h1=0,h2=0,l1=0,l2=0,k1=0,k2=0;
	for(long long i=x;i<=y;i++){
		if(a[i]=='A'){
			h1++;
		}else if(a[i]=='T'){
			l1++;
		}else if(a[i]=='C'){
			k1++;
		}
		if(b[i]=='A'){
			h2++;
		}else if(b[i]=='T'){
			l2++;
		}else if(b[i]=='C'){
			k2++;
		}
	}
	if(h1==h2 && l1==l2 && k1==k2){
		long long j=0;
		for(long long i=x;i<=y;i++){
			if(a[i]!=b[i]){
				j+=1;
			}
		}
		if(j%2==1){
			j+=1;
		}
		return j/2;
	}else{
		return -1;
	}
}

Compilation message (stderr)

dna.cpp: In function 'int get_distance(long long int, long long int)':
dna.cpp:12:6: error: 'a' was not declared in this scope
   12 |   if(a[i]=='A'){
      |      ^
dna.cpp:19:6: error: 'b' was not declared in this scope
   19 |   if(b[i]=='A'){
      |      ^
dna.cpp:30:7: error: 'a' was not declared in this scope
   30 |    if(a[i]!=b[i]){
      |       ^
dna.cpp:30:13: error: 'b' was not declared in this scope
   30 |    if(a[i]!=b[i]){
      |             ^