This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//IOI 2021
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int cnta[N][3];
int cntb[N][3];
int ps[N];
void init(string a, string b){
int n=a.size();
vector<int> enc = {'A', 'C', 'T'};
for(int i=0; i<n; i++){
for(int j=0; j<3; j++){
cnta[i+1][j] = cnta[i][j-1];
cntb[i+1][j] = cntb[i][j-1];
if(a[i] == enc[j]){
cnta[i+1][j]++;
}
if(b[i] == enc[j]){
cntb[i+1][j]++;
}
}
}
for(int i=0; i<n; i++){
ps[i+1] = ps[i] + (a[i]!=b[i]);
}
}
int get_distance(int x, int y){
for(int j=0; j<3; j++){
if(cnta[y+1][j]-cnta[x][j] != cntb[y+1][j]-cntb[x][j]){
return -1;
}
}
int ans = (ps[y+1] - ps[x] + 1)/2;
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... |