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;
#define ll int
#define sz(x) (ll)x.size()
#define MID ((l+r)/2)
#define F first
#define S second
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define pb push_back
#define ins insert
#define inf 1e9
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
vi a1,c1,a2,c2,f;
ll getRange(vi &v, ll l, ll r){
if (l == 0) return v[r];
return v[r] - v[l-1];
}
void init(string a, string b){
ll n = sz(a);
a1.resize(n),a2.resize(n),c1.resize(n),c2.resize(n),f.resize(n);
a1[0] = (a[0]=='A');
a2[0] = (b[0]=='A');
c1[0] = (a[0] == 'C');
c2[0] = (b[0] == 'C');
f[0] = (a[0] == b[0]);
for (ll i =1; i<n; i++){
a1[i] = (a[i]=='A') + a1[i-1];
a2[i] = (b[i]=='A') + a2[i-1];
c1[i] = (a[i] == 'C') + c1[i-1];
c2[i] = (b[i] == 'C') + c2[i-1];
f[i] = (a[i] == b[i]) + f[i-1];
}
// printVct(a1);
// printVct(a2);
// printVct(c1);
// printVct(c2);
// printVct(f);
}
int get_distance(int x, int y) {
if (getRange(a1,x,y) == getRange(a2,x,y) && getRange(c1,x,y) == getRange(c2,x,y)){
ll range = y-x+1;
ll dif = range - getRange(f, x,y);
ll ans = (dif%2) + dif/2;
return ans;
}
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... |