# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069928 | erdemfurkan | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 KiB |
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"
using namespace std;
string A;
string B;
int prea[3][100007];
int preb[3][100007];
int prec[100007];
void init(string a, string b) {
A = a;
B = b;
}
int get_distance(int x, int y) {
x++;
y++;
int i = prea[0][y] - prea[0][x-1];
int j = prea[1][y] - prea[1][x-1];
int k = prea[2][y] - prea[2][x-1];
int ii = preb[0][y] - preb[0][x-1];
int jj = preb[1][y] - preb[1][x-1];
int kk = preb[2][y] - preb[2][x-1];
if(ii != i || jj != j || kk != k) {
return -1;
}
int l = y-x+1;
return (l - (prec[y] - prec[x-1] + 1))/2;
}
int main() {
for(int i = 0; i < A.length(); i++) {
prea[0][i+1] = prea[0][i] + (A[i] == 'A');
}
for(int i = 0; i < A.length(); i++) {
prea[1][i+1] = prea[1][i] + (A[i] == 'T');
}
for(int i = 0; i < A.length(); i++) {
prea[2][i+1] = prea[2][i] + (A[i] == 'C');
}
for(int i = 0; i < B.length(); i++) {
preb[0][i+1] = preb[0][i] + (B[i] == 'A');
}
for(int i = 0; i < B.length(); i++) {
preb[1][i+1] = preb[1][i] + (B[i] == 'T');
}
for(int i = 0; i < B.length(); i++) {
preb[2][i+1] = preb[2][i] + (B[i] == 'C');
}
for(int i = 0; i < A.length(); i++) {
prec[i+1] = prec[i] + (A[i] == B[i]);
}
}