#include<bits/stdc++.h>
#include "dna.h"
using namespace std;
string A,B;
int p[100000][3][3],i,c,d,e,f,g,j,k,h[3][3],ch[100000][3],ch1[100000][3],dif[2][3],ans;
for(i=0;i<3;i++){
ch[-1][i]=0;
ch1[-1][i]=0;
for(j=0;j<3;j++){
p[-1][i][j]=0;
}
}
void init(string a,string b){
for(i=0;i<a.size();i++){
if(a[i]=='A'){
d=0;
}
else if(a[i]=='C'){
d=1;
}
else{
d=2;
}
if(b[i]=='A'){
e=0;
}
else if(b[i]=='C'){
e=1;
}
else{
e=2;
}
for(j=0;j<3;j++){
if(j==d){
ch[i][j]=ch[i-1][j]+1;
}
else{
ch[i][j]=ch[i-1][j];
}
if(j==e){
ch1[i][j]=ch1[i-1][j]+1;
}
else{
ch1[i][j]=ch1[i-1][j];
}
for(k=0;k<3;k++){
if(j==d&&k==e){
p[i][j][k]=p[i-1][j][k]+1;
}
else{
p[i][j][k]=p[i-1][j][k];
}
}
}
}
}
int get_distanse(int x,int y){
ans=0;
for(i=0;i<3;i++){
dif[0][0]=ch[y][0]-ch[x-1][0];
dif[0][1]=ch[y][1]-ch[x-1][1];
dif[0][2]=ch[y][2]-ch[x-1][2];
dif[1][0]=ch1[y][0]-ch1[x-1][0];
dif[1][1]=ch1[y][1]-ch1[x-1][1];
dif[1][2]=ch1[y][2]-ch1[x-1][2];
for(j=0;j<3;j++){
h[i][j]=p[y][i][j]-p[x-1][i][j]l
}
}
if(dif[0][0]!=dif[1][0]||dif[0][1]!=dif[1][1]||dif[0][2]!=dif[1][2]){
return -1;
}
f=min(h[0][1],min(h[1][2],h[2][0]));
g=min(h[1][0],min(h[2][1],h[0][2]));
ans+=(f+g)*2;
h[0][1]-=f;
h[1][2]-=f;
h[2][0]-=f;
h[1][0]-=g;
h[2][1]-=g;
h[0][2]-=g;
return ans+h[0][1]+h[1][2]+h[2][0];
}
Compilation message
dna.cpp:6:1: error: expected unqualified-id before 'for'
6 | for(i=0;i<3;i++){
| ^~~
dna.cpp:6:9: error: 'i' does not name a type
6 | for(i=0;i<3;i++){
| ^
dna.cpp:6:13: error: 'i' does not name a type
6 | for(i=0;i<3;i++){
| ^
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:14:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(i=0;i<a.size();i++){
| ~^~~~~~~~~
dna.cpp: In function 'int get_distanse(int, int)':
dna.cpp:67:38: error: expected ';' before 'l'
67 | h[i][j]=p[y][i][j]-p[x-1][i][j]l
| ^
| ;