이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |