# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527589 | vivaan_gupta | Mutating DNA (IOI21_dna) | C++17 | 1580 ms | 3744 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;
const int N = 1e5 + 5;
string A, B;
void init(std::string a, std::string b) {
A = a, B = b;
return;
}
int get_distance(int x, int y) {
vector<int> v;
vector<int> v2;
for(int i = x;i <= y;i++){
if(A[i] == 'A')
v.push_back(0);
else if(A[i] == 'C')
v.push_back(1);
else
v.push_back(2);
if(B[i] == 'A')
v2.push_back(0);
else if(B[i] == 'C')
v2.push_back(1);
else
v2.push_back(2);
}
// for(auto x:v){
// cout << x << " ";
// }
// cout<<"\n";
// for(auto x:v2){
// cout << x << " ";
// }
// cout << "\n\n";
vector<int> o = v;
sort(v.begin(), v.end());
int ans = 1e9;
do{
int cnt = 0;
bool ok = 1;
for(int i = 0;i < v.size();i++){
cnt += (o[i] != v[i]);
ok &= (v[i] == v2[i]);
}
if(!ok) continue;
ans = min(ans, ((cnt+1)/2));
}while(next_permutation(v.begin(), v.end()));
if(ans == 1e9) ans = -1;
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... |