제출 #1141948

#제출 시각아이디문제언어결과실행 시간메모리
1141948codewithjadmezMutating 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_c_d != cout_c_f){
	    return -1;
	}
	int i,j;
	i=j=y;
	int count=0;
	bool x_change = false;
	while(i>=x){
	    if(x_change){
	       	j=y;
	       	x_change = false;
	    }
	    if(i>=x){
	        while(d[i]==f[j] && i!=j){
	            count++;
	            i--;
	            x_change = true;
	        }
	    }
	    j--;
    
	}
	
	return count-1;
}
#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...