# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705490 | jakobrs | Mutating DNA (IOI21_dna) | C++17 | 43 ms | 4868 KiB |
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 <xmmintrin.h>
#include <iostream>
#include <vector>
struct Count {
int at, ca, tc;
int qw;
Count() : at(0), ca(0), tc(0), qw(0) {}
inline Count operator-(Count rhs) const {
Count result = *this;
result.at -= rhs.at;
result.ca -= rhs.ca;
result.tc -= rhs.tc;
result.qw -= rhs.qw;
return result;
}
};
std::string a, b;
std::vector<Count> prefixes;
void init(std::string A, std::string B) {
a = A;
b = B;
prefixes.reserve(A.size() + 1);
Count count;
prefixes.push_back(count);
for (int i = 0; i < A.size(); i++) {
if (A[i] == 'A' && B[i] == 'T') count.at += 1;
if (A[i] == 'T' && B[i] == 'A') count.at -= 1;
if (A[i] == 'C' && B[i] == 'A') count.ca += 1;
if (A[i] == 'A' && B[i] == 'C') count.ca -= 1;
if (A[i] == 'T' && B[i] == 'C') count.tc += 1;
if (A[i] == 'C' && B[i] == 'T') count.tc -= 1;
if (A[i] != B[i]) count.qw += 1;
prefixes.push_back(count);
}
}
int get_distance(int x, int y) {
y += 1;
Count count = prefixes[y] - prefixes[x];
if (!(count.at == count.ca && count.ca == count.tc)) return -1;
int total =
count.qw - std::abs(count.at) - std::abs(count.tc) - std::abs(count.ca);
total /= 2;
return total + std::abs(count.at) * 2;
}
Compilation message (stderr)
# | 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... |