Submission #529203

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

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:7:2: error: 'vector' was not declared in this scope
    7 |  vector<int>A;
      |  ^~~~~~
dna.cpp:7:9: error: expected primary-expression before 'int'
    7 |  vector<int>A;
      |         ^~~
dna.cpp:8:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int i=0;i<=a.length();i++){
      |              ~^~~~~~~~~~~~
dna.cpp:10:4: error: 'A' was not declared in this scope
   10 |    A.push_back(1);
      |    ^
dna.cpp:12:4: error: 'A' was not declared in this scope
   12 |    A.push_back(0);
      |    ^
dna.cpp:16:3: error: 'A' was not declared in this scope
   16 |   A[i]+=A[i-1];
      |   ^
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:41:8: error: 'A' was not declared in this scope
   41 |  int j=A[y]-A[x]+1;
      |        ^