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 <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";
const int MAXN = 100228;
int cnt[MAXN][3][3];
void init(string a, string b) {
string alf = "ACT";
for (int i = 1; i <= sz(a); i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
cnt[i][j][k] = cnt[i - 1][j][k] + (a[i - 1] == alf[j] && b[i - 1] == alf[k]);
}
}
}
}
int get_distance(int l, int r) {
int res = 0, prv = 0;
for (int i = 0; i < 3; i++) {
int j = (i + 1) % 3;
int x = cnt[r + 1][i][j] - cnt[l][i][j];
int y = cnt[r + 1][j][i] - cnt[l][j][i];
if (i != 0) {
if (prv != x - y) {
return -1;
}
} else {
res += 2 * abs(x - y);
prv = x - y;
}
res += min(x, y);
}
return res;
}
/**
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//read(FILENAME);
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... |