Submission #1142049

#TimeUsernameProblemLanguageResultExecution timeMemory
1142049codewithjadmezMutating DNA (IOI21_dna)C++20
0 / 100
19 ms2368 KiB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
string d;
string f;
void init(std::string a, std::string b) {
	d=a;
	f=b;
}

int get_distance(int x, int y) {
	int cout_a_d=0,cout_c_d=0,cout_t_d=0,cout_a_f=0,cout_c_f=0,cout_t_f=0;
	for(int i=x; i<y+1; i++) {
        if(d[i] == 'A'){
            cout_a_d++;
        }
        else if(d[i]== 'T'){
            cout_t_d++;
        }
        else{
            cout_c_d++;
        }
        if(f[i] == 'A'){
            cout_a_f++;
        }
        else if(f[i]== 'T'){
            cout_t_f++;
        }
        else{
            cout_c_f++;
        }
	}
	if(cout_a_d != cout_a_f){
	    return -1;
	}
	if(cout_t_d != cout_t_f){
	    return -1;
	}
	if(cout_t_d != cout_t_f){
	    return -1;
	}

	int i,j;
	i=j=y;
	int count=0;
	//int all_same = 0;
	//bool x_change = false;
    while (i >= x && j >= x) {
        while (i >= x && d[i] != f[j]) {
            count++;   
            i--; 
        }
        i--;
        j--;
    }

	return count;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...