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 <bits/stdc++.h>
#include "dna.h"
using namespace std;
const int MAXN = 1e5 + 5;
const char DNA[] = "ACT";
int cnt[MAXN][3][3];
int get_id(char c) {
return strchr(DNA, c) - DNA;
}
void init(string a, string b) {
for (int i = 0; i < a.size(); i++) {
if (i)
memcpy(cnt[i], cnt[i - 1], sizeof cnt[i]);
cnt[i][get_id(a[i])][get_id(b[i])]++;
}
}
int get_cnt(int x, int y, int i, int j) {
return cnt[y][i][j] - (x ? cnt[x - 1][i][j] : 0);
}
int get_distance(int x, int y) {
int res = 0;
for (int i = 0; i < 3; i++)
for (int j = 0; j < i; j++) {
int p = get_cnt(x, y, i, j);
int q = get_cnt(x, y, j, i);
if (p < q)
swap(p, q);
res += (2 * p + q + 2) / 3;
}
return res;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:15:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for (int i = 0; i < a.size(); i++) {
| ~~^~~~~~~~~~
# | 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... |