Submission #658952

#TimeUsernameProblemLanguageResultExecution timeMemory
658952BananMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.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 const INF = LONG_LONG_MAX; 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:11:17: error: 'LONG_LONG_MAX' was not declared in this scope
   11 | int const INF = LONG_LONG_MAX;
      |                 ^~~~~~~~~~~~~
dna.cpp:15:1: error: 'vector' does not name a type
   15 | vector<int> cna(100005, 0), cnt(100005, 0), cnc(100005, 0);
      | ^~~~~~
dna.cpp:16:1: error: 'vector' does not name a type
   16 | 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:23:23: error: 'cna' was not declared in this scope
   23 |         if(a[i]=='A'){cna[i]=cna[i-1]+1;}else{cna[i]=cna[i-1];}
      |                       ^~~
dna.cpp:23:47: error: 'cna' was not declared in this scope
   23 |         if(a[i]=='A'){cna[i]=cna[i-1]+1;}else{cna[i]=cna[i-1];}
      |                                               ^~~
dna.cpp:24:23: error: 'cna' was not declared in this scope
   24 |         if(b[i]=='A'){cna[i]--;}
      |                       ^~~
dna.cpp:26:23: error: 'cnt' was not declared in this scope; did you mean 'int'?
   26 |         if(a[i]=='T'){cnt[i]=cnt[i-1]+1;}else{cnt[i]=cnt[i-1];}
      |                       ^~~
      |                       int
dna.cpp:26:47: error: 'cnt' was not declared in this scope; did you mean 'int'?
   26 |         if(a[i]=='T'){cnt[i]=cnt[i-1]+1;}else{cnt[i]=cnt[i-1];}
      |                                               ^~~
      |                                               int
dna.cpp:27:23: error: 'cnt' was not declared in this scope; did you mean 'int'?
   27 |         if(b[i]=='T'){cnt[i]--;}
      |                       ^~~
      |                       int
dna.cpp:29:23: error: 'cnc' was not declared in this scope
   29 |         if(a[i]=='C'){cnc[i]=cnc[i-1]+1;}else{cnc[i]=cnc[i-1];}
      |                       ^~~
dna.cpp:29:47: error: 'cnc' was not declared in this scope
   29 |         if(a[i]=='C'){cnc[i]=cnc[i-1]+1;}else{cnc[i]=cnc[i-1];}
      |                                               ^~~
dna.cpp:30:23: error: 'cnc' was not declared in this scope
   30 |         if(b[i]=='C'){cnc[i]--;}
      |                       ^~~
dna.cpp:32:36: error: 'ac' was not declared in this scope; did you mean 'a'?
   32 |         if(a[i]=='A' && b[i]=='C'){ac[i]=ac[i-1]+1;}else{ac[i]=ac[i-1];}
      |                                    ^~
      |                                    a
dna.cpp:32:58: error: 'ac' was not declared in this scope; did you mean 'a'?
   32 |         if(a[i]=='A' && b[i]=='C'){ac[i]=ac[i-1]+1;}else{ac[i]=ac[i-1];}
      |                                                          ^~
      |                                                          a
dna.cpp:33:36: error: 'att' was not declared in this scope
   33 |         if(a[i]=='A' && b[i]=='T'){att[i]=att[i-1]+1;}else{att[i]=att[i-1];}
      |                                    ^~~
dna.cpp:33:60: error: 'att' was not declared in this scope
   33 |         if(a[i]=='A' && b[i]=='T'){att[i]=att[i-1]+1;}else{att[i]=att[i-1];}
      |                                                            ^~~
dna.cpp:35:36: error: 'ta' was not declared in this scope; did you mean 'a'?
   35 |         if(a[i]=='T' && b[i]=='A'){ta[i]=ta[i-1]+1;}else{ta[i]=ta[i-1];}
      |                                    ^~
      |                                    a
dna.cpp:35:58: error: 'ta' was not declared in this scope; did you mean 'a'?
   35 |         if(a[i]=='T' && b[i]=='A'){ta[i]=ta[i-1]+1;}else{ta[i]=ta[i-1];}
      |                                                          ^~
      |                                                          a
dna.cpp:36:36: error: 'tc' was not declared in this scope; did you mean 'tm'?
   36 |         if(a[i]=='T' && b[i]=='C'){tc[i]=tc[i-1]+1;}else{tc[i]=tc[i-1];}
      |                                    ^~
      |                                    tm
dna.cpp:36:58: error: 'tc' was not declared in this scope; did you mean 'tm'?
   36 |         if(a[i]=='T' && b[i]=='C'){tc[i]=tc[i-1]+1;}else{tc[i]=tc[i-1];}
      |                                                          ^~
      |                                                          tm
dna.cpp:38:36: error: 'ca' was not declared in this scope; did you mean 'a'?
   38 |         if(a[i]=='C' && b[i]=='A'){ca[i]=ca[i-1]+1;}else{ca[i]=ca[i-1];}
      |                                    ^~
      |                                    a
dna.cpp:38:58: error: 'ca' was not declared in this scope; did you mean 'a'?
   38 |         if(a[i]=='C' && b[i]=='A'){ca[i]=ca[i-1]+1;}else{ca[i]=ca[i-1];}
      |                                                          ^~
      |                                                          a
dna.cpp:39:36: error: 'ct' was not declared in this scope
   39 |         if(a[i]=='C' && b[i]=='T'){ct[i]=ct[i-1]+1;}else{ct[i]=ct[i-1];}
      |                                    ^~
dna.cpp:39:58: error: 'ct' was not declared in this scope
   39 |         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:47:12: error: 'cna' was not declared in this scope
   47 |         if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;}
      |            ^~~
dna.cpp:47:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   47 |         if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;}
      |                         ^~~
      |                         int
dna.cpp:47:38: error: 'cnc' was not declared in this scope
   47 |         if(cna[y]!=0 || cnt[y]!=0 || cnc[y]!=0){return -1;}
      |                                      ^~~
dna.cpp:48:12: error: 'cna' was not declared in this scope
   48 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |            ^~~
dna.cpp:48:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
   48 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                  ^~~
      |                                  int
dna.cpp:48:56: error: 'cnc' was not declared in this scope
   48 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                                        ^~~
dna.cpp:49:18: error: 'ca' was not declared in this scope
   49 |         ans+=min(ca[y], ac[y]);
      |                  ^~
dna.cpp:49:25: error: 'ac' was not declared in this scope; did you mean 'sc'?
   49 |         ans+=min(ca[y], ac[y]);
      |                         ^~
      |                         sc
dna.cpp:49:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   49 |         ans+=min(ca[y], ac[y]);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 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:50:18: error: 'ta' was not declared in this scope; did you mean 'tm'?
   50 |         ans+=min(ta[y], att[y]);
      |                  ^~
      |                  tm
dna.cpp:50:25: error: 'att' was not declared in this scope
   50 |         ans+=min(ta[y], att[y]);
      |                         ^~~
dna.cpp:51:18: error: 'tc' was not declared in this scope; did you mean 'tm'?
   51 |         ans+=min(tc[y], ct[y]);
      |                  ^~
      |                  tm
dna.cpp:51:25: error: 'ct' was not declared in this scope
   51 |         ans+=min(tc[y], ct[y]);
      |                         ^~
dna.cpp:52:9: error: 'vector' was not declared in this scope
   52 |         vector<int> v(3);
      |         ^~~~~~
dna.cpp:52:16: error: expected primary-expression before 'int'
   52 |         vector<int> v(3);
      |                ^~~
dna.cpp:53:9: error: 'v' was not declared in this scope
   53 |         v[0]=max(ca[y], ac[y])-min(ca[y], ac[y]);
      |         ^
dna.cpp:53:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   53 |         v[0]=max(ca[y], ac[y])-min(ca[y], ac[y]);
      |              ^~~
      |              std::max
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
dna.cpp:56:9: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   56 |         sort(all(v));
      |         ^~~~
      |         qsort
dna.cpp:61:12: error: 'cna' was not declared in this scope
   61 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |            ^~~
dna.cpp:61:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
   61 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                  ^~~
      |                                  int
dna.cpp:61:56: error: 'cnc' was not declared in this scope
   61 |         if(cna[y]-cna[x-1]!=0 || cnt[y]-cnt[x-1]!=0 || cnc[y]-cnc[x-1]!=0){return -1;}
      |                                                        ^~~
dna.cpp:62:18: error: 'ca' was not declared in this scope
   62 |         ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |                  ^~
dna.cpp:62:33: error: 'ac' was not declared in this scope; did you mean 'sc'?
   62 |         ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |                                 ^~
      |                                 sc
dna.cpp:62:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   62 |         ans+=min(ca[y]-ca[x-1], ac[y]-ac[x-1]);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 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:63:18: error: 'ta' was not declared in this scope; did you mean 'tm'?
   63 |         ans+=min(ta[y]-ta[x-1], att[y]-att[x-1]);
      |                  ^~
      |                  tm
dna.cpp:63:33: error: 'att' was not declared in this scope
   63 |         ans+=min(ta[y]-ta[x-1], att[y]-att[x-1]);
      |                                 ^~~
dna.cpp:64:18: error: 'tc' was not declared in this scope; did you mean 'tm'?
   64 |         ans+=min(tc[y]-tc[x-1], ct[y]-ct[x-1]);
      |                  ^~
      |                  tm
dna.cpp:64:33: error: 'ct' was not declared in this scope
   64 |         ans+=min(tc[y]-tc[x-1], ct[y]-ct[x-1]);
      |                                 ^~
dna.cpp:65:9: error: 'vector' was not declared in this scope
   65 |         vector<int> v(3);
      |         ^~~~~~
dna.cpp:65:16: error: expected primary-expression before 'int'
   65 |         vector<int> v(3);
      |                ^~~
dna.cpp:66:9: error: 'v' was not declared in this scope
   66 |         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:66:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   66 |         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/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
dna.cpp:69:9: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   69 |         sort(all(v));
      |         ^~~~
      |         qsort