Submission #1142633

#TimeUsernameProblemLanguageResultExecution timeMemory
1142633younesb13Mutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "dna.h"

using namespace std;
string A;
string dna_b;
void init(string a, string b) {
    A=a;
    A=b;
    return;
}
int get_distance(int y, int x) {
    int a=0;
    int t=0;
    int r=0;
    for (int i=y;i<x+1;i++) {
        if(A[i]=='A') {
            a++;
        }
        if(B[i]=='A') {
            a--;
        }
        if(A[i]=='T') {
            t++;
        }
        if(B[i]=='T') {
            t--;
        }
        if(A[i]!=B[i]) {
            r++;
        }
    }
    if (a==0 && t==0) {
        return r/2+r%2;
    }
    else {
        return -1;
    }
}

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:20:12: error: 'B' was not declared in this scope
   20 |         if(B[i]=='A') {
      |            ^
dna.cpp:26:12: error: 'B' was not declared in this scope
   26 |         if(B[i]=='T') {
      |            ^
dna.cpp:29:18: error: 'B' was not declared in this scope
   29 |         if(A[i]!=B[i]) {
      |                  ^