이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m, q, k, x, y, a, b, c;
map<char, int> mpa[100001];
map<char, int> mpb[100001];
map< pair<char, char>, int > mp[100001];
void init(string a, string b) {
for (int i = 0; i < a.size(); i++) {
mp[i + 1] = mp[i];
mp[i + 1][{a[i], b[i]}]++;
mpa[i + 1] = mpa[i];
mpb[i + 1] = mpb[i];
mpa[i + 1][a[i]]++;
mpb[i + 1][b[i]]++;
}
}
int get_distance(int x, int y) {
for (auto i : {'A', 'T', 'C'}) {
// cout << i << ' ' << mpa[y + 1][i] - mpa[x][i] << ' ' << mpb[y + 1][i] - mpb[x][i] << '\n';
if (mpa[y + 1][i] - mpa[x][i] != mpb[y + 1][i] - mpb[x][i]) {
return -1;
}
}
map< pair<char, char>, int > mp1;
for (auto i : mp[y + 1]) {
mp1[i.first] = i.second - mp[x][i.first];
}
int ans = 0;
ll e;
e = min(mp1[{'A', 'T'}], mp1[{'T', 'A'}]);
ans += e;
mp1[{'A', 'T'}] -= e;
mp1[{'T', 'A'}] -= e;
e = min(mp1[{'A', 'C'}], mp1[{'C', 'A'}]);
ans += e;
mp1[{'A', 'C'}] -= e;
mp1[{'C', 'A'}] -= e;
e = min(mp1[{'C', 'T'}], mp1[{'T', 'C'}]);
ans += e;
mp1[{'C', 'T'}] -= e;
mp1[{'T', 'C'}] -= e;
e = min({mp1[{'A', 'T'}], mp1[{'T', 'C'}], mp1[{'C', 'A'}]});
ans += e * 2;
mp1[{'A', 'T'}] -= e;
mp1[{'T', 'C'}] -= e;
mp1[{'C', 'A'}] -= e;
e = min({mp1[{'T', 'A'}], mp1[{'C', 'T'}], mp1[{'A', 'C'}]});
ans += e * 2;
mp1[{'T', 'A'}] -= e;
mp1[{'C', 'T'}] -= e;
mp1[{'A', 'C'}] -= e;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | 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... |