#include "dna.h"
#include <vector>
#include <iostream>
#include <unordered_map>
#define N 100001
using namespace std;
vector <int> s1;
vector <int> s2;
unordered_map <char,int> convert;
void init(std::string a, std::string b) {
convert['A'] = 0;
convert['C'] = 1;
convert['T'] = 2;
for (int i = 0; i < a.size(); ++i){
s1.push_back(convert[a[i]]);
s2.push_back(convert[b[i]]);
}
}
int get_distance(int x, int y) {
vector<int> occ1(3,0);
vector<int> occ2(3,0);
vector<int>section1;
vector<int>section2;
for (int i = x; i <= y; ++i){
occ1[s1[i]]++;
section1.push_back(s1[i]);
}
for (int i = x; i <= y; ++i){
occ2[s2[i]]++;
section2.push_back(s2[i]);
}
if (occ1 != occ2){
return -1;
}
// for (int i: section1){
// cout<<i<<' ';
// }cout<<endl;
if (section1 == section2){
return 0;
}
swap(section1[0], section1[1]);
if (section1 == section2){
return 1;
}
swap(section1[0], section1[1]);
swap(section1[1], section1[2]);
if (section1 == section2){
return 1;
}
swap(section1[1], section1[2]);
swap(section1[0], section1[2]);
if (section1 == section2){
return 1;
}
swap(section1[0], section1[2]);
return 2;
}
# | 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... |