Submission #740481

#TimeUsernameProblemLanguageResultExecution timeMemory
740481BerryisbetterRainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> #include <vector> using ll=long long; vector<ll> seg,br,d;ll n; vector<pair<ll,ll>>j; ll qw(ll a,ll b){ ll ans=0; for (a+=n,b+=n;a<b;a/=2,b/=2){ if (a%2){ ans=max(ans,seg[a]); a++; } if (b%2){ b--; ans=max(ans,seg[b]); } } return ans; } ll ind(ll v,ll a,ll b){ if (a==b){ return a; } ll m=(a+b)/2; if (qw(a,m)>=v){ return ind(v,a,m); } return ind(v,m+1,b); } /*#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<ll> a(n), r(n); for (ll i = 0; i < n; i++) { cin >> a[i]; r[i] = i - 1; } for (ll i = 0; i < n; i++) { ll j = i; while (r[j] != -1) { if (a[i] > a[r[j]]) { break; } j = r[j]; } r[i] = r[j]; cout << r[i] + 1 << '\n'; } }*/ void init(int N, std::vector<int> H) { n=N; seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n; //segment setup for (ll i=0;i<n;i++){ seg[i+n]=H[i]; } for (ll i=n;i>0;i--){ seg[i]=max(seg[2*i],seg[2*i+1]); } //br setup br=vector<ll>(n,0);for (ll i=0;i<n;i++){br[i]=i+1;} for (ll i = n-1; i >= 0; i--) { ll j = i; while (br[j] != n) { if (a[i] < a[r[j]]) { break; } j = br[j]; } br[i] = br[j]; } //distance d=vector<ll>(n+1);d[n]=0; for (ll i=0;i<n;i++){ d[i]=d[br[i]]+1; } } //ind,qw,d int minimum_jumps(int A, int B, int C, int D) { ll x=ind(seg[B+n],seg[C+n],seg[D+n]); if (d[B]>d[x]){ return d[B]-d[x]; } return -1; }

Compilation message (stderr)

jumps.cpp:6:1: error: 'vector' does not name a type
    6 | vector<ll> seg,br,d;ll n;
      | ^~~~~~
jumps.cpp:7:1: error: 'vector' does not name a type
    7 | vector<pair<ll,ll>>j;
      | ^~~~~~
jumps.cpp: In function 'll qw(ll, ll)':
jumps.cpp:12:16: error: 'seg' was not declared in this scope
   12 |    ans=max(ans,seg[a]);
      |                ^~~
jumps.cpp:12:8: error: 'max' was not declared in this scope; did you mean 'std::max'?
   12 |    ans=max(ans,seg[a]);
      |        ^~~
      |        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 jumps.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)
      |     ^~~
jumps.cpp:17:16: error: 'seg' was not declared in this scope
   17 |    ans=max(ans,seg[b]);
      |                ^~~
jumps.cpp:17:8: error: 'max' was not declared in this scope; did you mean 'std::max'?
   17 |    ans=max(ans,seg[b]);
      |        ^~~
      |        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 jumps.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)
      |     ^~~
jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:57:2: error: 'seg' was not declared in this scope
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |  ^~~
jumps.cpp:57:6: error: 'vector' was not declared in this scope
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |      ^~~~~~
jumps.cpp:57:6: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from jumps.h:1,
                 from jumps.cpp:1:
/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 jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
jumps.cpp:57:15: error: expected primary-expression before '>' token
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |               ^
jumps.cpp:57:18: warning: left operand of comma operator has no effect [-Wunused-value]
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |                 ~^~
jumps.cpp:57:24: error: 'j' was not declared in this scope
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |                        ^
jumps.cpp:57:33: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |                                 ^~~~
      |                                 std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
jumps.cpp:57:40: error: expected primary-expression before ',' token
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |                                        ^
jumps.cpp:57:43: error: expected primary-expression before '>>' token
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |                                           ^~
jumps.cpp:63:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
   63 |   seg[i]=max(seg[2*i],seg[2*i+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 jumps.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)
      |     ^~~
jumps.cpp:66:2: error: 'br' was not declared in this scope
   66 |  br=vector<ll>(n,0);for (ll i=0;i<n;i++){br[i]=i+1;}
      |  ^~
jumps.cpp:66:14: error: expected primary-expression before '>' token
   66 |  br=vector<ll>(n,0);for (ll i=0;i<n;i++){br[i]=i+1;}
      |              ^
jumps.cpp:66:16: warning: left operand of comma operator has no effect [-Wunused-value]
   66 |  br=vector<ll>(n,0);for (ll i=0;i<n;i++){br[i]=i+1;}
      |                ^
jumps.cpp:70:8: error: 'a' was not declared in this scope
   70 |    if (a[i] < a[r[j]]) {
      |        ^
jumps.cpp:70:17: error: 'r' was not declared in this scope
   70 |    if (a[i] < a[r[j]]) {
      |                 ^
jumps.cpp:78:2: error: 'd' was not declared in this scope
   78 |  d=vector<ll>(n+1);d[n]=0;
      |  ^
jumps.cpp:78:13: error: expected primary-expression before '>' token
   78 |  d=vector<ll>(n+1);d[n]=0;
      |             ^
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:85:11: error: 'seg' was not declared in this scope
   85 |  ll x=ind(seg[B+n],seg[C+n],seg[D+n]);
      |           ^~~
jumps.cpp:86:6: error: 'd' was not declared in this scope
   86 |  if (d[B]>d[x]){
      |      ^