# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009421 | jakobrs | Mutating DNA (IOI21_dna) | C++17 | 25 ms | 7056 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.
#pragma GCC target("avx2")
#include <string>
#include <vector>
using i32x4 [[gnu::vector_size(32)]] = int;
union Count {
struct {
int at, ca, tc;
int qw;
};
i32x4 vec;
Count() : at(0), ca(0), tc(0), qw(0) {}
Count(i32x4 vec) : vec(vec) {}
auto operator-(auto rhs) const -> Count {
return { vec - rhs.vec };
}
auto operator+(auto rhs) const -> Count {
return { vec + rhs.vec };
}
};
std::vector<Count> prefixes;
void init(std::string a, std::string b) {
prefixes.reserve(a.size() + 1);
Count count;
prefixes.push_back(count);
for (size_t i = 0; i < a.size(); i++) {
Count c1;
c1.at += a[i] == 'A' && b[i] == 'T';
c1.at -= a[i] == 'T' && b[i] == 'A';
c1.ca += a[i] == 'C' && b[i] == 'A';
c1.ca -= a[i] == 'A' && b[i] == 'C';
c1.tc += a[i] == 'T' && b[i] == 'C';
c1.tc -= a[i] == 'C' && b[i] == 'T';
if (a[i] != b[i]) c1.qw += 1;
prefixes.push_back(count = count + c1);
}
}
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;
return (count.qw + 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... |