이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l); i<=(r); ++i)
#define REP(i,l,r) for(int i=(l); i<(r); ++i)
#define FORD(i,r,l) for(int i=(r); i>=(l); --i)
#define REPD(i,r,l) for(int i=(r)-1; i>=(l); --i)
using namespace std;
const int N = 1e5 + 5;
int M[256];
int pre[N][3][3];
void init(string a, string b) {
M['A'] = 0; M['T'] = 1; M['C'] = 2;
REP(i, 0, a.length()) {
REP(j, 0, 3) REP(w, 0, 3) pre[i + 1][j][w] = pre[i][j][w];
if (a[i] != b[i]) ++pre[i + 1][M[a[i]]][M[b[i]]];
}
}
int choice[3][3];
int num[3];
int get_distance(int x, int y) {
++y;
REP(i, 0, 3) num[i] = 0;
REP(i, 0, 3) REP(j, 0, 3) {
choice[i][j] = pre[y][i][j] - pre[x][i][j];
num[i] += choice[i][j];
num[j] -= choice[i][j];
}
REP(i, 0, 3) if (num[i]) return -1;
int res = 0, m1 = 1e5, m2 = 1e5;
REP(i, 0, 3) REP(j, i + 1, 3) {
int tmp = min(choice[i][j], choice[j][i]);
res += tmp;
m2 = min(m2, max(choice[i][j], choice[j][i]) - tmp);
if (m2 < m1) swap(m1, m2);
}
return res + m1 + m2;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:3:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
3 | #define REP(i,l,r) for(int i=(l); i<(r); ++i)
| ^
dna.cpp:13:5: note: in expansion of macro 'REP'
13 | REP(i, 0, a.length()) {
| ^~~
dna.cpp:15:46: warning: array subscript has type 'char' [-Wchar-subscripts]
15 | if (a[i] != b[i]) ++pre[i + 1][M[a[i]]][M[b[i]]];
| ^
dna.cpp:15:55: warning: array subscript has type 'char' [-Wchar-subscripts]
15 | if (a[i] != b[i]) ++pre[i + 1][M[a[i]]][M[b[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... |