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;
char c[3] = {'A','C','T'};
vector<vector<int>> v(3), w(3);
vector<int> p;
void init(string a, string b) {
int n = a.size();
for(int i=0;i<3;i++) v[i].resize(n+1), w[i].resize(n+1);
p.resize(n+1);
for(int i=0;i<n;i++) for(int j=0;j<3;j++) v[j][i+1] = (a[i]==c[j])+v[j][i], w[j][i+1] = (b[i]==c[j])+w[j][i];
for(int i=0;i<n;i++) p[i+1] = p[i]+(a[i]!=b[i]);
}
int get_distance(int x, int y) {
bool yes = true;
for(int i=0;i<3;i++) if(v[i][y+1]-v[i][x] != w[i][y+1]-w[i][x]) yes = false;
if(yes) return (p[y+1]-p[x]+1)/2;
else return -1;
}
# | 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... |