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 "dna.h"
#include <bits/stdc++.h>
using namespace std;
string a,b;
vector<pair<int,int>>va,vb;
vector<int>dif;
void gen(void) {
va.resize(a.length()+1);
vb.resize(b.length()+1);
dif.resize(a.length()+1);
va[0]={0,0},vb[0]={0,0};
dif[0]=0;
for(int i = 0 ; i < a.size() ; i++) {
va[i+1]=va[i],vb[i+1]=vb[i],dif[i+1]=dif[i];
if(a[i]=='A') va[i+1].first++;
else if(a[i]=='C') va[i+1].second++;
if(b[i]=='A') vb[i+1].first++;
else if(b[i]=='C') vb[i+1].second++;
if(a[i] != b[i]) dif[i+1]++;
} return;
}
int get_distance(int x, int y) {
int aa=va[y+1].first-va[x].first,cc=va[y+1].second-va[x].second;
if(aa-(vb[y+1].first-vb[x].first) || cc-(vb[y+1].second-vb[x].second)) {
return -1;
}
return (dif[y+1]-dif[x]+1)/2;
}
void init(string aa, string bb) {
a=aa,b=bb;
gen();
}
Compilation message (stderr)
dna.cpp: In function 'void gen()':
dna.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | 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... |