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 forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<int> vi;
string a, b;
void init(std::string a, std::string b) {
::a = a;
::b = b;
}
int id(char v) {
return v == 'A' ? 0 : v == 'C' ? 1 : 2;
}
int get_distance(int x, int y) {
int cnt[3][3];
forR(i, 3) forR(j, 3) cnt[i][j] = 0;
REP(i, x, y+1) {
cnt[id(a[i])][id(b[i])]++;
}
int ab=min(cnt[0][1], cnt[1][0]), ac=min(cnt[0][2], cnt[2][0]), bc=min(cnt[1][2], cnt[2][1]);
cnt[0][1]-=ab, cnt[1][0]-=ab;
cnt[0][2]-=ac, cnt[2][0]-=ac;
cnt[1][2]-=bc, cnt[2][1]-=bc;
int abt=max(cnt[0][1], cnt[1][0]), act=max(cnt[0][2], cnt[2][0]), bct=max(cnt[1][2], cnt[2][1]);
if(abt == act && act == bct) {
return ab + ac + bc + 2 * abt;
} else return -1;
}
# | 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... |