이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
struct my_hash {
inline size_t operator()(const pair<int, int>& a) const {
return a.first * 31 + a.second;
}
};
string s, t;
string act = "ACT";
vector<int> cnt[3];
vector<int> x[3][3];
void init(string s_, string t_) {
s = s_;
t = t_;
int n = s.size();
for (int i = 0; i < 3; i++) {
cnt[i].resize(n + 1);
for (int j = 0; j < n; j++) {
cnt[i][j + 1] = cnt[i][j] + (act[i] == s[j]) - (act[i] == t[j]);
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
x[i][j].resize(n + 1);
for (int k = 0; k < n; k++) {
x[i][j][k + 1] = x[i][j][k] + (act[i] == s[k] && act[j] == t[k]);
}
}
}
}
int get_distance(int l, int r) {
r++;
for (int i = 0; i < 3; i++) {
if (cnt[i][r] != cnt[i][l]) {
return -1;
}
}
int ab = x[0][1][r] - x[0][1][l];
int ba = x[1][0][r] - x[1][0][l];
int bc = x[1][2][r] - x[1][2][l];
int cb = x[2][1][r] - x[2][1][l];
int ca = x[2][0][r] - x[2][0][l];
int ac = x[0][2][r] - x[0][2][l];
int ans = min(ab, ba) + min(bc, cb) + min(ac, ca) + abs(ab - ba) * 2;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization ("O3")
|
dna.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization ("unroll-loops")
|
# | 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... |