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;
typedef long long ll;
typedef vector<int>vi;
typedef string str;
#define pb push_back
#define sz(v) (int)v.size()
#define FOR(i,a,b) for(int i=a; i<b; i++)
//-------------------------------------------------
const int MX=1e5+10;
int p[3][3][MX];
void init(str a, str b){
map<char,int>mp; mp['A']=0; mp['C']=1; mp['T']=2;
memset(p,0,sizeof(p));
int N=sz(a);
FOR(i,0,N){
p[mp[a[i]]][mp[b[i]]][i]=1;
}
FOR(x,0,3) FOR(y,0,3) FOR(i,1,N) p[x][y][i]+=p[x][y][i-1];
}
int get_distance(int l, int r) {
int n=0,ans=0;
FOR(x,0,3) FOR(y,x+1,3){
int v1=p[x][y][r];
if(l) v1-=p[x][y][l-1];
int v2=p[y][x][r];
if(l) v2-=p[y][x][l-1];
ans+=min(v1,v2);
n+=max(v1,v2)-min(v1,v2);
}
if(n%3) return -1;
ans+=(n/3)*2;
return ans;
}
# | 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... |