This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
#include "dna.h"
int n;
int p[6][maxn];
void init(string a, string b) {
n = a.size();
for(int i = 0; i < n; i++){
if(a[i] == b[i]){
if(i)for(int j = 0; j < 6; j++)p[j][i] += p[j][i - 1];
continue;
}
int ok = (a[i] > b[i]), x = 0;
if(ok)swap(a[i], b[i]);
if(b[i] == 'T' && a[i] == 'A')swap(a[i], b[i]);
if(a[i] == 'C')x = 2;
if(a[i] == 'T')x = 4;
x += ok;
p[x][i]++;
if(i)for(int j = 0; j < 6; j++)p[j][i] += p[j][i - 1];
}
}
int get_distance(int x, int y) {
int ret = 0;
int a[6], b[6];
for(int j = 0; j < 6; j++)a[j] = p[j][y];
if(x)for(int j = 0; j < 6; j++)a[j] -= p[j][x - 1];
for(int j = 0; j < 6; j++){
if(j % 2)b[j] = max(a[j] - a[j - 1], 0);
else b[j] = max(a[j] - a[j + 1], 0);
}
ret += min(a[0], a[1]) + min(a[2], a[3]) + min(a[4], a[5]);
swap(b[5], b[4]);
if(b[0] == b[2] && b[2] == b[4])ret += b[0] * 2;
else return -1;
if(b[1] == b[3] && b[3] == b[5])ret += b[1] * 2;
else return -1;
return ret;
}
//void solve() {
//int n, q;
//string a, b;
//cin >> n >> q >> a >> b;
//init(a, b);
//while(q--){
//int l, r;
//cin >> l >> r;
//cout << get_distance(l, r) << '\n';
//}
//}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//int times = 1;
////cin >> times;
//for(int i = 1; i <= times; i++) {
//solve();
//}
//return 0;
//}
# | 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... |