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;
int ps[(int)(1e5+1)][3][2], pr[(int)(1e5+1)][6];
void init(std::string a, std::string b) {
int n=a.size();
a='i'+a, b='i'+b;
for(int i=1; i<=n; ++i) {
ps[i][0][0]=ps[i-1][0][0];
ps[i][1][0]=ps[i-1][1][0];
ps[i][2][0]=ps[i-1][2][0];
ps[i][0][1]=ps[i-1][0][1];
ps[i][1][1]=ps[i-1][1][1];
ps[i][2][1]=ps[i-1][2][1];
if(a[i]=='A') ++ps[i][0][0];
else if(a[i]=='C') ++ps[i][1][0];
else ++ps[i][2][0];
if(b[i]=='A') ++ps[i][0][1];
else if(b[i]=='C') ++ps[i][1][1];
else ++ps[i][2][1];
for(int j=0; j<6; ++j) pr[i][j]=pr[i-1][j];
if(a[i]=='A'&&b[i]=='C') ++pr[i][0];
if(a[i]=='C'&&b[i]=='A') ++pr[i][1]; //1
if(a[i]=='A'&&b[i]=='T') ++pr[i][2]; //1
if(a[i]=='T'&&b[i]=='A') ++pr[i][3];
if(a[i]=='C'&&b[i]=='T') ++pr[i][4];
if(a[i]=='T'&&b[i]=='C') ++pr[i][5]; //1
}
}
int get_distance(int x, int y) {
++x, ++y;
for(int i=0; i<3; ++i) {
if((ps[y][i][0]-ps[x-1][i][0])!=(ps[y][i][1]-ps[x-1][i][1])) {
return -1;
}
}
vector<int> v;
for(int i=0; i<6; ++i) v.push_back(pr[y][i]-pr[x-1][i]);
// for(int x:v) cout << x << " ";
// cout << "\n";
int p=min(v[0], v[1]), q=min(v[2], v[3]), r=min(v[4], v[5]);
v[0]-=p, v[1]-=p;
int ans=p+q+r;
ans+=2*max(v[0], v[1]);
return ans;
}
//int main() {
// int n;
// cin >> n;
// string a, b;
// cin >> a >> b;
// init(a, b);
// cout << get_distance(1, 3) << "\n";
//
//}
# | 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... |