Submission #658954

#TimeUsernameProblemLanguageResultExecution timeMemory
658954BananMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include <bits/stdc++.h> using ll = long long; #define double long double #define endl '\n' #define sz(a) (int)a.size() #define pb push_back #define fs first #define sc second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() int n; vector<int> cna(100005, 0), cnt(100005, 0), cnc(100005, 0); vector<int> ac(100005, 0), att(100005, 0), ta(100005, 0), tc(100005, 0), ca(100005, 0), ct(100005, 0); void init(std::string a, std::string b) { n=sz(a); for(int i=0;i<n;i++) { if(a[i]=='A'){cna[i]=cna[i-1]+1;}else{cna[i]=cna[i-1];} if(b[i]=='A'){cna[i]--;} if(a[i]=='T'){cnt[i]=cnt[i-1]+1;}else{cnt[i]=cnt[i-1];} if(b[i]=='T'){cnt[i]--;} if(a[i]=='C'){cnc[i]=cnc[i-1]+1;}else{cnc[i]=cnc[i-1];} if(b[i]=='C'){cnc[i]--;} if(a[i]=='A' && b[i]=='C'){ac[i]=ac[i-1]+1;}else{ac[i]=ac[i-1];} if(a[i]=='A' && b[i]=='T'){att[i]=att[i-1]+1;}else{att[i]=att[i-1];} if(a[i]=='T' && b[i]=='A'){ta[i]=ta[i-1]+1;}else{ta[i]=ta[i-1];} if(a[i]=='T' && b[i]=='C'){tc[i]=tc[i-1]+1;}else{tc[i]=tc[i-1];} if(a[i]=='C' && b[i]=='A'){ca[i]=ca[i-1]+1;}else{ca[i]=ca[i-1];} if(a[i]=='C' && b[i]=='T'){ct[i]=ct[i-1]+1;}else{ct[i]=ct[i-1];} } } int get_distance(int x, int y) { int ans=0; if(x==0) { if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;} if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;} ans+=min(ca[y], ac[y]); ans+=min(ta[y], att[y]); ans+=min(tc[y], ct[y]); vector<int> v(3); v[0]=max(ca[y], ac[y])-min(ca[y], ac[y]); v[1]=max(ta[y], att[y])-min(ta[y], att[y]); v[2]=max(tc[y], ct[y])-min(tc[y], ct[y]); sort(all(v)); ans+=v[0]+v[1]; } else { if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;} ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]); ans+=min(ta[y]-ta[x-1], att[y]-att[x-1]); ans+=min(tc[y]-tc[x-1], ct[y]-ct[x-1]); vector<int> v(3); v[0]=max(ca[y]-ca[x-1], ac[y]-ac[x-1])-min(ca[y]-ca[x-1], ac[y]-ac[x-1]); v[1]=max(ta[y]-ta[x-1], att[y]-att[x-1])-min(ta[y]-ta[x-1], att[y]-att[x-1]); v[2]=max(tc[y]-tc[x-1], ct[y]-ct[x-1])-min(tc[y]-tc[x-1], ct[y]-ct[x-1]); sort(all(v)); ans+=v[0]+v[1]; } return ans; }

Compilation message (stderr)

dna.cpp:14:1: error: 'vector' does not name a type
   14 | vector<int> cna(100005, 0), cnt(100005, 0), cnc(100005, 0);
      | ^~~~~~
dna.cpp:15:1: error: 'vector' does not name a type
   15 | vector<int> ac(100005, 0), att(100005, 0), ta(100005, 0), tc(100005, 0), ca(100005, 0), ct(100005, 0);
      | ^~~~~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:22:23: error: 'cna' was not declared in this scope
   22 |         if(a[i]=='A'){cna[i]=cna[i-1]+1;}else{cna[i]=cna[i-1];}
      |                       ^~~
dna.cpp:22:47: error: 'cna' was not declared in this scope
   22 |         if(a[i]=='A'){cna[i]=cna[i-1]+1;}else{cna[i]=cna[i-1];}
      |                                               ^~~
dna.cpp:23:23: error: 'cna' was not declared in this scope
   23 |         if(b[i]=='A'){cna[i]--;}
      |                       ^~~
dna.cpp:25:23: error: 'cnt' was not declared in this scope; did you mean 'int'?
   25 |         if(a[i]=='T'){cnt[i]=cnt[i-1]+1;}else{cnt[i]=cnt[i-1];}
      |                       ^~~
      |                       int
dna.cpp:25:47: error: 'cnt' was not declared in this scope; did you mean 'int'?
   25 |         if(a[i]=='T'){cnt[i]=cnt[i-1]+1;}else{cnt[i]=cnt[i-1];}
      |                                               ^~~
      |                                               int
dna.cpp:26:23: error: 'cnt' was not declared in this scope; did you mean 'int'?
   26 |         if(b[i]=='T'){cnt[i]--;}
      |                       ^~~
      |                       int
dna.cpp:28:23: error: 'cnc' was not declared in this scope
   28 |         if(a[i]=='C'){cnc[i]=cnc[i-1]+1;}else{cnc[i]=cnc[i-1];}
      |                       ^~~
dna.cpp:28:47: error: 'cnc' was not declared in this scope
   28 |         if(a[i]=='C'){cnc[i]=cnc[i-1]+1;}else{cnc[i]=cnc[i-1];}
      |                                               ^~~
dna.cpp:29:23: error: 'cnc' was not declared in this scope
   29 |         if(b[i]=='C'){cnc[i]--;}
      |                       ^~~
dna.cpp:31:36: error: 'ac' was not declared in this scope; did you mean 'a'?
   31 |         if(a[i]=='A' && b[i]=='C'){ac[i]=ac[i-1]+1;}else{ac[i]=ac[i-1];}
      |                                    ^~
      |                                    a
dna.cpp:31:58: error: 'ac' was not declared in this scope; did you mean 'a'?
   31 |         if(a[i]=='A' && b[i]=='C'){ac[i]=ac[i-1]+1;}else{ac[i]=ac[i-1];}
      |                                                          ^~
      |                                                          a
dna.cpp:32:36: error: 'att' was not declared in this scope
   32 |         if(a[i]=='A' && b[i]=='T'){att[i]=att[i-1]+1;}else{att[i]=att[i-1];}
      |                                    ^~~
dna.cpp:32:60: error: 'att' was not declared in this scope
   32 |         if(a[i]=='A' && b[i]=='T'){att[i]=att[i-1]+1;}else{att[i]=att[i-1];}
      |                                                            ^~~
dna.cpp:34:36: error: 'ta' was not declared in this scope; did you mean 'a'?
   34 |         if(a[i]=='T' && b[i]=='A'){ta[i]=ta[i-1]+1;}else{ta[i]=ta[i-1];}
      |                                    ^~
      |                                    a
dna.cpp:34:58: error: 'ta' was not declared in this scope; did you mean 'a'?
   34 |         if(a[i]=='T' && b[i]=='A'){ta[i]=ta[i-1]+1;}else{ta[i]=ta[i-1];}
      |                                                          ^~
      |                                                          a
dna.cpp:35:36: error: 'tc' was not declared in this scope; did you mean 'tm'?
   35 |         if(a[i]=='T' && b[i]=='C'){tc[i]=tc[i-1]+1;}else{tc[i]=tc[i-1];}
      |                                    ^~
      |                                    tm
dna.cpp:35:58: error: 'tc' was not declared in this scope; did you mean 'tm'?
   35 |         if(a[i]=='T' && b[i]=='C'){tc[i]=tc[i-1]+1;}else{tc[i]=tc[i-1];}
      |                                                          ^~
      |                                                          tm
dna.cpp:37:36: error: 'ca' was not declared in this scope; did you mean 'a'?
   37 |         if(a[i]=='C' && b[i]=='A'){ca[i]=ca[i-1]+1;}else{ca[i]=ca[i-1];}
      |                                    ^~
      |                                    a
dna.cpp:37:58: error: 'ca' was not declared in this scope; did you mean 'a'?
   37 |         if(a[i]=='C' && b[i]=='A'){ca[i]=ca[i-1]+1;}else{ca[i]=ca[i-1];}
      |                                                          ^~
      |                                                          a
dna.cpp:38:36: error: 'ct' was not declared in this scope
   38 |         if(a[i]=='C' && b[i]=='T'){ct[i]=ct[i-1]+1;}else{ct[i]=ct[i-1];}
      |                                    ^~
dna.cpp:38:58: error: 'ct' was not declared in this scope
   38 |         if(a[i]=='C' && b[i]=='T'){ct[i]=ct[i-1]+1;}else{ct[i]=ct[i-1];}
      |                                                          ^~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:46:12: error: 'cna' was not declared in this scope
   46 |         if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;}
      |            ^~~
dna.cpp:46:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   46 |         if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;}
      |                         ^~~
      |                         int
dna.cpp:46:38: error: 'cnc' was not declared in this scope
   46 |         if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;}
      |                                      ^~~
dna.cpp:47:12: error: 'cna' was not declared in this scope
   47 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |            ^~~
dna.cpp:47:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
   47 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                  ^~~
      |                                  int
dna.cpp:47:56: error: 'cnc' was not declared in this scope
   47 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                                        ^~~
dna.cpp:48:18: error: 'ca' was not declared in this scope
   48 |         ans+=min(ca[y], ac[y]);
      |                  ^~
dna.cpp:48:25: error: 'ac' was not declared in this scope; did you mean 'sc'?
   48 |         ans+=min(ca[y], ac[y]);
      |                         ^~
      |                         sc
dna.cpp:48:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   48 |         ans+=min(ca[y], ac[y]);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
dna.cpp:49:18: error: 'ta' was not declared in this scope; did you mean 'tm'?
   49 |         ans+=min(ta[y], att[y]);
      |                  ^~
      |                  tm
dna.cpp:49:25: error: 'att' was not declared in this scope
   49 |         ans+=min(ta[y], att[y]);
      |                         ^~~
dna.cpp:50:18: error: 'tc' was not declared in this scope; did you mean 'tm'?
   50 |         ans+=min(tc[y], ct[y]);
      |                  ^~
      |                  tm
dna.cpp:50:25: error: 'ct' was not declared in this scope
   50 |         ans+=min(tc[y], ct[y]);
      |                         ^~
dna.cpp:51:9: error: 'vector' was not declared in this scope
   51 |         vector<int> v(3);
      |         ^~~~~~
dna.cpp:51:9: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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 /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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:51:16: error: expected primary-expression before 'int'
   51 |         vector<int> v(3);
      |                ^~~
dna.cpp:52:9: error: 'v' was not declared in this scope
   52 |         v[0]=max(ca[y], ac[y])-min(ca[y], ac[y]);
      |         ^
dna.cpp:52:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   52 |         v[0]=max(ca[y], ac[y])-min(ca[y], ac[y]);
      |              ^~~
      |              std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
dna.cpp:55:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   55 |         sort(all(v));
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
dna.cpp:60:12: error: 'cna' was not declared in this scope
   60 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |            ^~~
dna.cpp:60:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
   60 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                  ^~~
      |                                  int
dna.cpp:60:56: error: 'cnc' was not declared in this scope
   60 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                                        ^~~
dna.cpp:61:18: error: 'ca' was not declared in this scope
   61 |         ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |                  ^~
dna.cpp:61:33: error: 'ac' was not declared in this scope; did you mean 'sc'?
   61 |         ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |                                 ^~
      |                                 sc
dna.cpp:61:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   61 |         ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
dna.cpp:62:18: error: 'ta' was not declared in this scope; did you mean 'tm'?
   62 |         ans+=min(ta[y]-ta[x-1], att[y]-att[x-1]);
      |                  ^~
      |                  tm
dna.cpp:62:33: error: 'att' was not declared in this scope
   62 |         ans+=min(ta[y]-ta[x-1], att[y]-att[x-1]);
      |                                 ^~~
dna.cpp:63:18: error: 'tc' was not declared in this scope; did you mean 'tm'?
   63 |         ans+=min(tc[y]-tc[x-1], ct[y]-ct[x-1]);
      |                  ^~
      |                  tm
dna.cpp:63:33: error: 'ct' was not declared in this scope
   63 |         ans+=min(tc[y]-tc[x-1], ct[y]-ct[x-1]);
      |                                 ^~
dna.cpp:64:9: error: 'vector' was not declared in this scope
   64 |         vector<int> v(3);
      |         ^~~~~~
dna.cpp:64:9: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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 /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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:64:16: error: expected primary-expression before 'int'
   64 |         vector<int> v(3);
      |                ^~~
dna.cpp:65:9: error: 'v' was not declared in this scope
   65 |         v[0]=max(ca[y]-ca[x-1], ac[y]-ac[x-1])-min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |         ^
dna.cpp:65:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   65 |         v[0]=max(ca[y]-ca[x-1], ac[y]-ac[x-1])-min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |              ^~~
      |              std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
dna.cpp:68:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   68 |         sort(all(v));
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~