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>
#define all(a) a.begin(), a.end()
using namespace std;
vector<int> a, b;
void init(std::string _a, std::string _b) {
a.resize(_a.size());
b.resize(_b.size());
for (int i = 0; i < (int) _a.size(); ++i) {
if (_a[i] == 'A') {
a[i] = 0;
} else if (_a[i] == 'T') {
a[i] = 1;
} else {
a[i] = 2;
}
if (_b[i] == 'A') {
b[i] = 0;
} else if (_b[i] == 'T') {
b[i] = 1;
} else {
b[i] = 2;
}
}
}
int get_distance(int x, int y) {
int sum = 0;
map<pair<int, int>, int> tmp;
multiset<int> s1, s2;
for (int i = x; i <= y; ++i) {
s1.insert(a[i]);
s2.insert(b[i]);
if (a[i] != b[i]) {
int a1 = a[i], a2 = b[i];
sum += 2;
if (tmp[{a2, a1}]) {
--tmp[{a2, a1}];
--sum;
} else {
++tmp[{a1, a2}];
}
}
}
if (s1 != s2) {
return -1;
}
return sum;
}
# | 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... |