# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1001963 | hacizadal | Mutating DNA (IOI21_dna) | C++17 | 1557 ms | 5468 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
string s, t;
ll p1[100005], p2[100005];
void init(std::string a, std::string b) {
s = a;
t = b;
for (ll i = 0; i<s.length(); i++){
p1[i+1] = p1[i];
p2[i+1] = p2[i];
if (s[i] != t[i]){
if (s[i] == 'A') p1[i+1]++;
else p2[i+1]++;
}
}
}
int get_distance(int x, int y) {
string k = s.substr(x, y-x+1);
string g = t.substr(x, y-x+1);
string a = k;
string b = g;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a != b){
return -1;
}
if (k == g){
return 0;
}
if (y - x <= 2){
if (k[1] == g[1] or k[0] == g[0] or k[2] == g[2]){
return 1;
}
else {
return 2;
}
}
return min(p1[y+1] - p1[x], p2[y+1] - p2[x]);
}
Compilation message (stderr)
# | 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... |