Submission #499691

#TimeUsernameProblemLanguageResultExecution timeMemory
499691sazid_alamMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" using namespace std; void init(string a, string b) { return 0; } int get_distance(int x, int y) { int p = 0, A[2] = {}, C[2] = {}, T[2] = {}; for(int i = x; i <= y; i++){ if(a[i] != b[i]) p++; if(a[i] == 'A') A[0]++; if(b[i] == 'A') A[1]++; if(a[i] == 'C') C[0]++; if(b[i] == 'C') C[1]++; if(a[i] == 'T') T[0]++; if(b[i] == 'T') T[1]++; } if(A[0] != A[1] || C[0] != C[1] || T[0] != T[1]) return -1; if(p % 2) return p / 2 + 1; else return p / 2; return 0; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:5:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
    5 |     return 0;
      |            ^
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:12:12: error: 'a' was not declared in this scope
   12 |         if(a[i] != b[i]) p++;
      |            ^
dna.cpp:12:20: error: 'b' was not declared in this scope
   12 |         if(a[i] != b[i]) p++;
      |                    ^
dna.cpp:13:12: error: 'a' was not declared in this scope
   13 |         if(a[i] == 'A') A[0]++;
      |            ^
dna.cpp:14:12: error: 'b' was not declared in this scope
   14 |         if(b[i] == 'A') A[1]++;
      |            ^
dna.cpp:15:12: error: 'a' was not declared in this scope
   15 |         if(a[i] == 'C') C[0]++;
      |            ^
dna.cpp:16:12: error: 'b' was not declared in this scope
   16 |         if(b[i] == 'C') C[1]++;
      |            ^
dna.cpp:17:12: error: 'a' was not declared in this scope
   17 |         if(a[i] == 'T') T[0]++;
      |            ^
dna.cpp:18:12: error: 'b' was not declared in this scope
   18 |         if(b[i] == 'T') T[1]++;
      |            ^