Submission #529183

#TimeUsernameProblemLanguageResultExecution timeMemory
529183Icebear16Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" int n,q; void init(std::string a, std::string b) { while(q--){ int x,y; return get_distance(x,y); } } int get_distance(int x, int y) { int h1,h2,l1,l2,k1,k2; for(int i=x;i<=y;i++){ if(a[i]=='A'){ h1++; }else if(a[i]=='T'){ l1++; }else if(a[i]=='C'){ k1++; } if(b[i]=='A'){ h2++; }else if(b[i]=='T'){ l2++; }else if(b[i]=='C'){ k2++; } } if(h1==h2 && l1==l2 && k1==k2){ int j=0; for(int i=x;i<=y;i++){ if(a[i]!=b[i]){ j+=1; } } if(j%2==1){ j+=1; } return j/2; }else{ return -1; } }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:6:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
    6 |   return get_distance(x,y);
      |          ~~~~~~~~~~~~^~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:12:6: error: 'a' was not declared in this scope
   12 |   if(a[i]=='A'){
      |      ^
dna.cpp:19:6: error: 'b' was not declared in this scope
   19 |   if(b[i]=='A'){
      |      ^
dna.cpp:30:7: error: 'a' was not declared in this scope
   30 |    if(a[i]!=b[i]){
      |       ^
dna.cpp:30:13: error: 'b' was not declared in this scope
   30 |    if(a[i]!=b[i]){
      |             ^