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<bits/stdc++.h>
using namespace std;
#include "dna.h"
int qs[100005][10],arr[10];
char one[10],two[10],alpha[]={'A','T','C'};
void init(std::string a, std::string b)
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
one[3*i+j+1]=alpha[i];
two[3*i+j+1]=alpha[j];
}
}
/*for(int i=1;i<=9;i++)
{
printf("%c %c\n",one[i],two[i]);
}*/
for(int i=0;i<a.size();i++)
{
for(int j=1;j<=9;j++)
{
if(one[j]==a[i]&&two[j]==b[i])
{
qs[i+1][j]=qs[i][j]+1;
}else
{
qs[i+1][j]=qs[i][j];
}
}
}
/*for(int i=1;i<=9;i++)
{
printf("%d %c %c\n",i,one[i],two[i]);
for(int j=1;j<=a.size();j++)
{
printf("%d ",qs[j][i]);
}
printf("\n");
}*/
}
int get_distance(int x, int y)
{
for(int i=1;i<=9;i++)
{
arr[i]=qs[y+1][i]-qs[x][i];
}
/*for(int i=1;i<=9;i++)
{
printf("%d ",arr[i]);
}
printf("\n");*/
if(arr[2]-arr[4]==arr[6]-arr[8]&&arr[2]-arr[4]==arr[7]-arr[3])
{
if(arr[2]>arr[4])
{
return arr[4]+arr[8]+arr[3]+(arr[2]-arr[4])*2;
}else
{
return arr[2]+arr[6]+arr[7]+(arr[4]-arr[2])*2;
}
}else
{
return -1;
}
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int i=0;i<a.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... |