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>
#include "dna.h"
using namespace std;
const int N = 1e5 + 5;
int p[N][8],a[8];
void init(string a, string b) {
//A,C,T
//AT - 1
//TA - 2
//AC - 3
//CA - 4
//CT - 5
//TC - 6
int n = a.size();
for (int i = 0; i < n; i++){
string s = ""; s+=a[i]; s+= b[i];
int id=0;
if (s == "AT") id=1;
else if (s == "TA") id = 2;
else if (s == "AC") id = 3;
else if (s == "CA") id = 4;
else if (s == "CT") id = 5;
else if (s == "TC") id = 6;
if (i){
for (int d = 1; d < 7; d++)
p[i][d] = p[i - 1][d];
}
p[i][id]++;
}
}
int get_distance(int x, int y) {
for (int d=1;d<7;d++){
a[d] = p[y][d];
if (x) a[d] -= p[x - 1][d];
}
int ans=0;
for (int d = 1; d < 7; d+=2){
int vl = min(a[d],a[d + 1]);
ans += vl;
a[d] -= vl,a[d+1]-=vl;
}
int mn = min({a[1],a[4],a[6]});
ans += mn*2;
a[1] -= mn,a[4] -= mn,a[6] -= mn;
//146
//ACT
//TAC
mn = min({a[2],a[3],a[5]});
ans += mn*2;
a[2] -= mn,a[3] -= mn,a[5] -= mn;
for (int i = 1; i < 7; i++)
if (a[i]) return -1;
//235
//TAC
//ACT
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... |