#include "dna.h"
#include <bits/stdc++.h>
int n, a_cnt, b_cnt;
int asum[100050][3], bsum[100050][3];
int cnt[100050];
void init(std::string a, std::string b){
n = (int)a.size();
for(int i = 0; i < n; i++){
if(a[i] == 'A') asum[i][0] ++;
else if(a[i] == 'C') asum[i][1] ++;
else asum[i][2]++;
if(b[i] == 'A') bsum[i][0] ++;
else if(b[i] == 'C') bsum[i][1] ++;
else bsum[i][2]++;
if(a[i] != b[i]) cnt[i] = 1;
}
for(int i = 1; i < n; i++){
cnt[i] += cnt[i - 1];
for(int j = 0; j < 3; j++){
asum[i][j] += asum[i - 1][j];
bsum[i][j] += bsum[i - 1][j];
}
}
}
int get_distance(int x, int y){
for(int j = 0; j < 3; j++){
if(asum[y][j] - asum[x - 1][j] != bsum[y][j] - bsum[x - 1][j]){
return -1;
}
}
return (cnt[y] - cnt[x - 1] + 2) / 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
4856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
4856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |