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 maxn = (int)1e5+1;
int index(char c){
if(c == 'A') return 0;
if(c == 'C') return 1;
return 2;
}
int parok[maxn][9] = {}, ell[maxn][3] = {};
void init(std::string a, std::string b) {
int n = (int)a.size();
for(int i = 0; i < n; i++){
ell[i+1][index(a[i])]++;
ell[i+1][index(b[i])]--;
parok[i+1][index(a[i]) + index(b[i])*3]++;
}
for(int i = 1; i <= n; i++){
for(int j = 0; j < 3; j++)
ell[i][j] += ell[i-1][j];
for(int j = 0; j < 9; j++)
parok[i][j] += parok[i-1][j];
}
}
int get_distance(int x, int y) {
for(int i = 0; i < 3; i++)
if(ell[y+1][i] - ell[x][i] != 0)
return -1;
vector<int> db(9, 0);
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
db[i+j*3] = parok[y+1][i+j*3] - parok[x][i+j*3];
return max(db[3], db[1]) + db[6] + db[7];
}
# | 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... |