# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1025308 | cpdreamer | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 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;
struct ct{
int a;
int c;
int t;
};
string s,t;
void init(std::string &a, std::string &b) {
s=a;
t=b;
}
bool compare (ct a,ct b){
if(a.a==b.a && a.c==b.c && a.t==b.t)
return true;
return false;
}
int get_distance(int x, int y) {
ct state_s={0, 0, 0};
ct state_t={0, 0, 0};
int c=y-x+1;
for(int i=x;i<=y;i++){
if(s[i]=='A')state_s.a++;
if(s[i]=='C')state_s.c++;
if(s[i]=='T')state_s.t++;
if(t[i]=='A')state_t.a++;
if(t[i]=='C')state_t.c++;
if(t[i]=='T')state_t.t++;
if(s[i]==t[i] || compare(state_s,state_t))c--;
if(i==y && !compare(state_s,state_t))
return -1;
}
return c;
}