Submission #858242

#TimeUsernameProblemLanguageResultExecution timeMemory
858242lentibearMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include <string> #include <vector> void init(std::string a, std::string b); int get_distance(int x, int y); vector<int> ct[6]; void init(std::string a, std::string b){ n=min(a.size(),b.size()); for(int j=0; j<6; j++) ct[j]= vector<int> (n); for(int i=0; i<n; i++) { if(i>0) for(int j=0; j<6; j++) ct[j][i]=ct[j][i-1]; else for(int j=0; j<6; j++) ct[j][i]=0; if(a[i]=='A'){ if(b[i]=='T') ct[0][i]++; else if (b[i]=='C') ct[1][i]++; } if(a[i]=='T'){ if(b[i]=='A') ct[2][i]++; else if (b[i]=='C') ct[3][i]++; } if(a[i]=='C'){ if(b[i]=='A') ct[4][i]++; else if (b[i]=='T') ct[5][i]++; } } int get_distance(int x, int y){ int nct[6]; for(int j=0; j<6; j++) nct[j]=ct[j][y]; if(x>0) for(int j=0; j<6; j++) nct[j]-=ct[j][x-1]; if(nct[0]+nct[1]==nct[2]+nct[4] && nct[2]+nct[3]==nct[0]+nct[5]){ return(min(nct[0], nct[2])+min(nct[1],nct[4])+min(nct[3],nct[5])+max(nct[0]-nct[2],0)*2+max(nct[1]-nct[4],0)*2); } return(-1); }

Compilation message (stderr)

dna.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> ct[6];
      | ^~~~~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:2: error: 'n' was not declared in this scope
    9 |  n=min(a.size(),b.size());
      |  ^
dna.cpp:9:4: error: 'min' was not declared in this scope; did you mean 'std::min'?
    9 |  n=min(a.size(),b.size());
      |    ^~~
      |    std::min
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
dna.cpp:10:25: error: 'ct' was not declared in this scope
   10 |  for(int j=0; j<6; j++) ct[j]= vector<int> (n);
      |                         ^~
dna.cpp:10:32: error: 'vector' was not declared in this scope
   10 |  for(int j=0; j<6; j++) ct[j]= vector<int> (n);
      |                                ^~~~~~
dna.cpp:10:32: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from dna.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
dna.cpp:10:39: error: expected primary-expression before 'int'
   10 |  for(int j=0; j<6; j++) ct[j]= vector<int> (n);
      |                                       ^~~
dna.cpp:12:39: error: 'ct' was not declared in this scope
   12 |        if(i>0) for(int j=0; j<6; j++) ct[j][i]=ct[j][i-1];
      |                                       ^~
dna.cpp:13:36: error: 'ct' was not declared in this scope
   13 |        else for(int j=0; j<6; j++) ct[j][i]=0;
      |                                    ^~
dna.cpp:15:26: error: 'ct' was not declared in this scope
   15 |            if(b[i]=='T') ct[0][i]++;
      |                          ^~
dna.cpp:16:32: error: 'ct' was not declared in this scope
   16 |            else if (b[i]=='C') ct[1][i]++;
      |                                ^~
dna.cpp:19:26: error: 'ct' was not declared in this scope
   19 |            if(b[i]=='A') ct[2][i]++;
      |                          ^~
dna.cpp:20:32: error: 'ct' was not declared in this scope
   20 |            else if (b[i]=='C') ct[3][i]++;
      |                                ^~
dna.cpp:23:26: error: 'ct' was not declared in this scope
   23 |            if(b[i]=='A') ct[4][i]++;
      |                          ^~
dna.cpp:24:32: error: 'ct' was not declared in this scope
   24 |            else if (b[i]=='T') ct[5][i]++;
      |                                ^~
dna.cpp:28:31: error: a function-definition is not allowed here before '{' token
   28 | int get_distance(int x, int y){
      |                               ^
dna.cpp:36:1: error: expected '}' at end of input
   36 | }
      | ^
dna.cpp:8:40: note: to match this '{'
    8 | void init(std::string a, std::string b){
      |                                        ^