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;
int prefa[100005][2], preft[100005][2], prefc[100005][2], prefmiss[100005];
void init(string a, string b) {
int n = a.length();
for (int i = 1; i <= n; i++) {
prefa[i][0] = prefa[i-1][0] + (a[i-1]=='A');
prefa[i][1] = prefa[i-1][1] + (b[i-1]=='A');
preft[i][0] = preft[i-1][0] + (a[i-1]=='T');
preft[i][1] = preft[i-1][1] + (b[i-1]=='T');
prefc[i][0] = prefc[i-1][0] + (a[i-1]=='C');
prefc[i][1] = prefc[i-1][1] + (b[i-1]=='C');
prefmiss[i] = prefmiss[i-1] + (a[i-1]!=b[i-1]);
}
}
int get_distance(int x, int y) {
y++;
if (prefa[y][0]-prefa[x][0] != prefa[y][1]-prefa[x][1]) {
return -1;
}
if (preft[y][0]-preft[x][0] != preft[y][1]-preft[x][1]) {
return -1;
}
if (preft[y][0]-preft[x][0] != preft[y][1]-preft[x][1]) {
return -1;
}
if (prefmiss[y]-prefmiss[x] == 1) {
return -1;
}
if (prefmiss[y]-prefmiss[x] == 0) {
return 0;
} else {
return prefmiss[y]-prefmiss[x]-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... |