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;
#define ar array
typedef long long ll;
//~ #define int ll
const int N = 1e5 + 5;
int is[N], pref[N];
ar<int, 3> c[2][N];
void init(string a, string b) {
//~ cout<<"here"<<endl;
int n = a.size();
for(int i=1;i<=n;i++){
pref[i] = pref[i - 1] + (a[i - 1] != b[i - 1]);
c[0][i] = c[0][i - 1], c[1][i] = c[1][i - 1];
{
int v;
if(a[i - 1] == 'A') v = 0;
if(a[i - 1] == 'C') v = 1;
if(a[i - 1] == 'T') v = 2;
c[0][i][v]++;
}
{
int v;
if(b[i - 1] == 'A') v = 0;
if(b[i - 1] == 'C') v = 1;
if(b[i - 1] == 'T') v = 2;
c[1][i][v]++;
}
}
}
ar<int, 3> get(int t, int x, int y){
ar<int, 3> ans {};
ans[0] = c[t][y][0] - c[t][x][0];
ans[1] = c[t][y][1] - c[t][x][1];
ans[2] = c[t][y][2] - c[t][x][2];
//~ cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<"\n";
return ans;
}
int get_distance(int x, int y) {
x++, y++;
if(get(0, x - 1, y) == get(1, x - 1, y)){
return (pref[y] - pref[x - 1]) / 2;
} else {
return -1;
}
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:31:13: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
31 | c[1][i][v]++;
| ^
dna.cpp:24:13: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
24 | c[0][i][v]++;
| ^
# | 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... |