Submission #443870

#TimeUsernameProblemLanguageResultExecution timeMemory
443870osmanallazovMutating DNA (IOI21_dna)C++17
21 / 100
44 ms3880 KiB
#include "dna.h"
#include<bits/stdc++.h>
using namespace std;
string q,w,e,r;
void init(std::string a, std::string b) {
    q=a;
    e=a;
    r=b;
    w=b;
}

int get_distance(int x, int y) {
    int b=0,c=0,t=0;
    int B=0,C=0,T=0;
    for(int i=x;i<=y;i++){
		if(q[i]=='A')
        b++;
		if(q[i]=='T')
		c++;
		if(q[i]=='C')
		t++;
		if(w[i]=='A')
		B++;
		if(w[i]=='T')
		C++;
		if(w[i]=='C')
		T++;
	}
	if(b!=B||c!=C||t!=T)
        return -1;
    if(y-x==0)
        return 0;
    if(y-x==1){
        if(q[x]==w[x]){
            return 0;
        }
        else{
            return 1;
        }
    }
    if(y-x==2){
        if(q[x]==w[x] && w[x+1]==w[x+1] && q[y]==w[y]){
        return 0;
        }
		else if(q[x]==w[x] || q[x+1]==w[x+1] || q[y]==w[y]){
		return 1;
		}
		else{
		return 2;
		}
    }
}

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
#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...