Submission #1204607

#TimeUsernameProblemLanguageResultExecution timeMemory
1204607tamzidMutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "dna.h"
using namespace std;

string A,B;

void init(std::string a, std::string b) {
	A = a;
	B = b;
}

int get_distance(int x, int y) {
	int c=0,d=0,e=0,f=0;
	for(int i=x;i<=y;++i)
	{
		if(B[i] == 'A')
			++c;
		else
			++d;
		if(B[i] =='A')
			++e;
		else
			++f;
	}
	if(e != f)
	{
		return -1;
	}
	int dif = 0;
	for(int i=x;i<=y;++i)
	{
		if(a[i] != b[i])
			++dif;
	}
	if(dif & 1)
		return -1;
	else
		return dif / 2;
	return 0;
}

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:32:20: error: 'a' was not declared in this scope
   32 |                 if(a[i] != b[i])
      |                    ^
dna.cpp:32:28: error: 'b' was not declared in this scope
   32 |                 if(a[i] != b[i])
      |                            ^