# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116322 | jtrh | Mutating DNA (IOI21_dna) | C++17 | 33 ms | 6420 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 "dna.h"
#include <vector>
std::vector<int> ca, ct, cc, aa, at, tc;
void init(std::string a, std::string b) {
ca.resize(a.size() + 1);
ct.resize(a.size() + 1);
cc.resize(a.size() + 1);
aa.resize(a.size() + 1);
at.resize(a.size() + 1);
tc.resize(a.size() + 1);
for (int i = 0; i < a.size(); ++i) {
ca[i + 1] = ca[i] + (a[i] == 'A') - (b[i] == 'A');
ct[i + 1] = ct[i] + (a[i] == 'T') - (b[i] == 'T');
cc[i + 1] = cc[i] + (a[i] == 'C') - (b[i] == 'C');
aa[i + 1] = aa[i] + ((a[i] == 'A') != (b[i] == 'A'));
at[i + 1] = at[i] + (a[i] == 'A' && b[i] == 'T') - (a[i] == 'T' && b[i] == 'A');
tc[i + 1] = tc[i] + ((a[i] == 'T' && b[i] == 'C') || (a[i] == 'C' && b[i] == 'T'));
}
}
int get_distance(int x, int y) {
if (ca[x] != ca[y + 1] || ct[x] != ct[y + 1] || cc[x] != cc[y + 1]) {
return -1;
}
return (aa[y + 1] - aa[x] + abs(at[y + 1] - at[x]) + tc[y + 1] - tc[x]) / 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... |