This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
string a,b;
void init(string A,string B)
{
a=A;
b=B;
}
int get_distance(int x,int y)
{
string a1,b1;
for (int i=x;i<=y;i++)
{
a1+=a[i];
b1+=b[i];
}
int aA=0,aC=0,aT=0,bA=0,bC=0,bT=0;
for (int i=0;i<a1.size();i++)
{
if (a1[i]=='A') aA++;
else if (a1[i]=='C') aC++;
else aT++;
if (b1[i]=='A') bA++;
else if (b1[i]=='C') bC++;
else bT++;
}
int br=0;
if (aA==bA&&aC==bC&&aT==bT)
{
for (int i=0;i<a1.size();i++)
if (a1[i]!=b1[i]) br++;
return br-1;
}
else
return -1;
}
/*
int main()
{
init("ATACAT", "ACTATA");
cout << get_distance(1,3) << endl;
cout << get_distance(4,5) << endl;
cout << get_distance(3,5) << endl;
return 0;
}*/
Compilation message (stderr)
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for (int i=0;i<a1.size();i++)
| ~^~~~~~~~~~
dna.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for (int i=0;i<a1.size();i++)
| ~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |