Submission #1142070

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

int get_distance(int x, int y) {
		string ax="";
        string bx="";
        int freq1[3]={0,0,0};
        int freq2[3]={0,0,0};
        for(int i=x;i<=y;i++){
            ax+=k[i];
            if(k[i]=='A')freq1[0]++;
            if(k[i]=='B')freq1[1]++;
            if(k[i]=='C')freq1[2]++;
            bx+=d[i];
            if(d[i]=='A')freq2[0]++;
            if(d[i]=='B')freq2[1]++;
            if(d[i]=='C')freq2[2]++;
        }
        if(freq1[0]!=freq2[0] or freq1[1]!=freq2[1] or freq1[2]!=freq2[2]){
            return -1;
        }
        if(y-x==2){
            //cout << ax << " " << bx;
            if(ax==bx){
                return 0;
            }else if((ax[0]==bx[1] and ax[1]==bx[0]) or (ax[2]==bx[1] and ax[1]==bx[2])){
                return 1;
            }else if(ax[0]==bx[2] and ax[2]==bx[0]){
                return 1;
            }else{
                return 2;
            }
        }else if(y-x==1){
            if(ax==bx){
                return 0;
            }else{
                return 1;
            }
        }else{
            return 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...