Submission #1052179

#TimeUsernameProblemLanguageResultExecution timeMemory
1052179PiokemonRainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; constexpr int N = 2e5; int h[N+9]; int l[N+9]; int r[N+9]; int dst[N+9]; int n; constexpr int base = (1<<18); int tree[2*base+9]; // min void sed(int x, int a, int b, int p, int k, int val){ if (b<p || k<a)return; if (p<=a && b<=k){ tree[x]=min(tree[x],val); return; } int mid=(a+b)/2; sed(2*x,a,mid,p,k,val); sed(2*x+1,mid+1,b,p,k,val); } int query(int x){ x+=base; int odp=1e9; while(x){ odp=min(odp,tree[x]); x/=2; } return odp; } bool stupido=1; void init(int N, std::vector<int> H) { n=N; for (int x=0;x<n;x++){ if (h[x]!=x+1)stupido=0; } for (int x=0;x<n;x++)h[x]=H[x]; for (int x=0;x<=2*base+2;x++)tree[x]=1e9; for (int x=n-1;x>=0;x--){ r[x]=query(h[x]); sed(1,0,base-1,0,h[x],x); } for (int x=0;x<=2*base+2;x++)tree[x]=1e9; for (int x=0;x<n;x++){ l[x]=-query(h[x]); sed(1,0,base-1,0,h[x],-x); } /*for (int x=0;x<n;x++){ cerr << l[x] << ' ' << r[x] << '\n'; }*/ return; } int minimum_jumps(int A, int B, int C, int D){ if (stupido){ int odp = 1e9; odp = min(odp,min(abs(A-C,B-C))); odp = min(odp,min(abs(A-D,B-D))); if (C<=B && B<=D)odp=0; if (C<=A && A<=D)odp=0; if (A<=C && D<=B)odp=0; } if (A==B && C==D){ int odp=0; while(A!=C){ if (A<C){ A=r[A]; odp++; } else if (A>C){ A=l[A]; odp++; } if (A==-1e9 || A==1e9){ odp=-1; break; } } return odp; } vector<int> kol; for (int x=0;x<n;x++)dst[x]=1e9; for (int x=A;x<=B;x++){ dst[x]=0; kol.push_back(x); } for (int y=0;y<(int)kol.size();y++){ if (C<=kol[y] && kol[y]<=D)return dst[kol[y]]; if (l[kol[y]]!=-1e9){ if (dst[l[kol[y]]]>dst[kol[y]]+1){ dst[l[kol[y]]]=dst[kol[y]]+1; kol.push_back(l[kol[y]]); } } if (r[kol[y]]!=1e9){ if (dst[r[kol[y]]]>dst[kol[y]]+1){ dst[r[kol[y]]]=dst[kol[y]]+1; kol.push_back(r[kol[y]]); } } } return -1; }

Compilation message (stderr)

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:64:34: error: no matching function for call to 'abs(int, int)'
   64 |     odp = min(odp,min(abs(A-C,B-C)));
      |                                  ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from jumps.cpp:2:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:840:12: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const std::valarray<_Tp>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
jumps.cpp:64:34: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   64 |     odp = min(odp,min(abs(A-C,B-C)));
      |                                  ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
jumps.cpp:64:34: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   64 |     odp = min(odp,min(abs(A-C,B-C)));
      |                                  ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from jumps.cpp:2:
/usr/include/c++/10/complex:625:5: note: candidate: 'template<class _Tp> _Tp std::abs(const std::complex<_Tp>&)'
  625 |     abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
      |     ^~~
/usr/include/c++/10/complex:625:5: note:   template argument deduction/substitution failed:
jumps.cpp:64:34: note:   mismatched types 'const std::complex<_Tp>' and 'int'
   64 |     odp = min(odp,min(abs(A-C,B-C)));
      |                                  ^
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:79:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
jumps.cpp:65:34: error: no matching function for call to 'abs(int, int)'
   65 |     odp = min(odp,min(abs(A-D,B-D)));
      |                                  ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from jumps.cpp:2:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:840:12: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const std::valarray<_Tp>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
jumps.cpp:65:34: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   65 |     odp = min(odp,min(abs(A-D,B-D)));
      |                                  ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
jumps.cpp:65:34: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   65 |     odp = min(odp,min(abs(A-D,B-D)));
      |                                  ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from jumps.cpp:2:
/usr/include/c++/10/complex:625:5: note: candidate: 'template<class _Tp> _Tp std::abs(const std::complex<_Tp>&)'
  625 |     abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
      |     ^~~
/usr/include/c++/10/complex:625:5: note:   template argument deduction/substitution failed:
jumps.cpp:65:34: note:   mismatched types 'const std::complex<_Tp>' and 'int'
   65 |     odp = min(odp,min(abs(A-D,B-D)));
      |                                  ^
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:79:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided