# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497319 | Maqsut_03 | Mutating DNA (IOI21_dna) | C++17 | 42 ms | 4736 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<bits/stdc++.h>
#include "dna.h"
using namespace std;
string a, b, a1, b1, a2;
int n;
char arr[26];
void init(string a0, string b0) {
a = a0;
b = b0;
a1 = a;
b1 = b;
n = a.length();
}
int get_distance(int x, int y) {
int ans = 0;
a = a1;
b = b1;
memset(arr, 0, sizeof(arr));
for (int i = x; i <= y; i++)
arr[a[i]]++, arr[b[i]]--;
for (int i = 0; i < 26; i++)
if (arr[i] != 0) return -1;
a = a.substr(x, y);
b = b.substr(x, y);
// cout << a <<" ";
for (int i=0;i<=y-x;i++){
bool ok=0;
for (int j=i+1;j<=y-x;j++){
if (a[i] == b[j] and a[i] != b[i] and a[j] == b[i]){
ok=1;
ans++;
swap(a[i], a[j]);
}
}
if (!ok){
for (int j=i+1;j<=y-x;j++){
if (a[i] == b[j] and a[i] != b[i]){
ans++;
swap(a[i], a[j]);
}
}
}
}
return ans;
}
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... |