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>
using namespace std;
int sums[100010][9];
int len;
void init(string a, string b) {
int thing[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
len = a.size();
for (int i = 0; i < a.size(); ++i) {
int app = 0;
if (a[i] == 'T') app += 6;
else if (a[i] == 'C') app += 3;
if (b[i] == 'T') app += 2;
else if (b[i] == 'C') app += 1;
// cout<<a[i]<<b[i]<<' '<<app<<'\n';
++thing[app];
for (int j = 0; j < 9; ++j) {
sums[i][j] = thing[j];
}
}
}
/*
A C T
A 0 1 2
C 3 4 5
T 6 7 8
*/
int get_distance(int x, int y) {
int ret[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i < 9; ++i) {
if (x == 0) {
ret[i] = sums[y][i];
} else {
ret[i] = sums[y][i] - sums[x - 1][i];
}
// cout<<ret[i]<<' ';
}
// cout<<'\n';
int out = 0;
int ACs = min(ret[1], ret[3]);
ret[1] -= ACs, ret[3] -= ACs;
int ATs = min(ret[2], ret[6]);
ret[2] -= ATs, ret[6] -= ATs;
int CTs = min(ret[5], ret[7]);
ret[5] -= CTs, ret[7] -= CTs;
out += ACs + ATs + CTs;
if (ret[1] != ret[5] || ret[5] != ret[6]) return -1;
if (ret[3] != ret[7] || ret[7] != ret[2]) return -1;
out += (ret[1] + ret[3]) * 2;
return out;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | 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... |