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 int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
int pref[1000000][3][3];
map<char,int> m;
void init(std::string a, std::string b) {
m['A']=0;
m['C']=1;
m['T']=2;
rep(j,0,3){
rep(k,0,3){
pref[0][j][k]=0;
}
}
rep(i,0,(int)a.size()){
rep(j,0,3){
rep(k,0,3){
pref[i+1][j][k]=pref[i][j][k];
}
}
pref[i+1][m[a[i]]][m[b[i]]]++;
}
}
int arr[3][3];
int get_distance(int x, int y) {
y++;
rep(i,0,3){
rep(j,0,3){
arr[i][j]=pref[y][i][j]-pref[x][i][j];
}
}
int bal[3];
rep(i,0,3)bal[i]=0;
rep(i,0,3){
rep(j,0,3){
bal[i]+=arr[i][j];
bal[j]-=arr[i][j];
}
}
rep(i,0,3){
if(bal[i]!=0)return -1;
}
int ans=0;
rep(i,0,3){
rep(j,0,3){
if(i==j)arr[i][j]=0;
int k=min(arr[i][j],arr[j][i]);
ans+=k;
arr[i][j]-=k;
arr[j][i]-=k;
//cerr<<arr[i][j]<<" ";
}//cerr<<endl;
}
int tot=0;
rep(i,0,3){
rep(j,0,3){
tot+=arr[i][j];
}
}
tot/=3;
tot*=2;
ans+=tot;
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... |