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>
#pragma GCC optimize ("O4")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")
using namespace std;
//#define int long long
#define ll long long
#define xx first
#define yy second
const int NMAX = 1e5;
int at[NMAX + 5], t[NMAX + 5], c[NMAX + 5];
int v[NMAX + 5];
string a, b;
void init (string as, string bs){
int n = as.length();
a = as;
b = bs;
for (int i = 1; i <= n; ++ i){
at[i] = at[i - 1];
t[i] = t[i - 1];
c[i] = c[i - 1];
v[i] = v[i - 1];
if (a[i - 1] == b[i - 1])
v[i] ++;
else if (a[i - 1] == 'A' && b[i - 1] == 'T')
at[i] ++;
else if (a[i - 1] == 'T' && b[i - 1] == 'A')
at[i] --;
else if (a[i - 1] == 'T' && b[i - 1] == 'C')
t[i] ++;
else if (a[i - 1] == 'C' && b[i - 1] == 'T')
t[i] --;
else if (a[i - 1] == 'C' && b[i - 1] == 'A')
c[i] ++;
else
c[i] --;
}
}
int get_distance(int x, int y){
y ++;
int unu = at[y] - at[x];
int doi = t[y] - t[x];
int trei = c[y] - c[x];
if (unu != doi || unu != trei)
return -1;
int val = abs (unu) * 2;
int ans = y - x;
ans -= (v[y] - v[x]);
ans -= abs(unu) * 3;
val += ans / 2;
return val;
}
# | 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... |