이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string A, B;
void init(std::string a, std::string b) {
A = a;
B = b;
}
int get_distance(int x, int y) {
string a = A.substr(x, y - x + 1);
string b = B.substr(x, y - x + 1);
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a != b)
return -1;
a = A.substr(x, y - x + 1);
b = B.substr(x, y - x + 1);
ll ans = 0;
vector <int> p;
for (int i = 0; i < y - x + 1; i++) {
if (b[i] == 'A' && a[i] != 'A')
p.push_back(i);
}
int pt = 0;
for (int j = 0; j < y - x + 1; j++) {
if (a[j] == 'A' && b[j] != 'A') {
ans += abs(p[pt] - j);
pt++;
}
}
return ans;
}
# | 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... |