Submission #522314

#TimeUsernameProblemLanguageResultExecution timeMemory
522314byunjaewooAliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define x first #define y second using namespace std; using ll=long long; using ld=long double; using pp=pair<ll, ll>; const int Nmax=100010; ll N, NN, M, K, DP[Nmax], C[Nmax]; pp A[Nmax], B[Nmax]; struct line { ll a, b; int idx; ll f(ll x) {return a*x+b;} ld cross(line r) {return (b-r.b)/(r.a-a);} }L[Nmax]; void Dynamic(ll v) { int fr=0, re=0; fill(C+1, C+N+1, 0); for(int i=1; i<=N; i++) { line tmp={-2*A[i].x, DP[i-1]+A[i].x*A[i].x-2*A[i].x, i}; while(fr<re && L[re-1].cross(tmp)>=L[re-1].cross(L[re])) re--; L[++re]=tmp; while(fr<re && L[fr].f(A[i].y)>=L[fr+1].f(A[i].y)) fr++; DP[i]=L[fr].f(A[i].y)+A[i].y*A[i].y+v+2*A[i].y+1; C[i]=C[L[fr].idx-1]+1; } } ll take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { NN=n, M=m, K=k; for(int i=1; i<=NN; i++) { B[i].x=min(r[i-1], c[i-1]), B[i].y=max(r[i-1], c[i-1]); } sort(B+1, B+NN+1); for(int i=NN; i>=1; i--) { while(N && A[N].y<=B[i].y) N--; A[++N]=B[i]; } reverse(A+1, A+N+1); K=min(K, N); { ll l=0, r=N+1, lv, rv; for(ll s=0, e=M*M; s<=e;) { ll mid=(s+e)/2; Dynamic(mid); if(C[N]==K) { return DP[N]-mid*C[N]; } else if(C[N]>K) { s=mid+1; if(r>C[N]) r=C[N], rv=DP[N]-mid*C[N]; } else { e=mid-1; if(l<C[N]) l=C[N], lv=DP[N]-mid*C[N]; } } } return rv+(lv-rv)/(r-l)*(r-K); }

Compilation message (stderr)

aliens.cpp: In function 'll take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:44:20: warning: variable 'lv' set but not used [-Wunused-but-set-variable]
   44 |     ll l=0, r=N+1, lv, rv;
      |                    ^~
aliens.cpp:44:24: warning: variable 'rv' set but not used [-Wunused-but-set-variable]
   44 |     ll l=0, r=N+1, lv, rv;
      |                        ^~
aliens.cpp:61:12: error: 'rv' was not declared in this scope; did you mean 'r'?
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |            ^~
      |            r
aliens.cpp:61:16: error: 'lv' was not declared in this scope; did you mean 'ld'?
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                ^~
      |                ld
aliens.cpp:61:26: error: 'l' was not declared in this scope
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                          ^
aliens.cpp:61:31: error: no match for 'operator-' (operand types are 'std::vector<int>' and 'll' {aka 'long long int'})
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                              ~^~
      |                              | |
      |                              | ll {aka long long int}
      |                              std::vector<int>
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  500 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1533:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1533 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1533:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/10/complex:361:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const std::complex<_Tp>&)'
  361 |     operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:361:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::complex<_Tp>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/10/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const _Tp&)'
  370 |     operator-(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:370:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::complex<_Tp>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/10/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const std::complex<_Tp>&)'
  379 |     operator-(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:379:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   mismatched types 'const std::complex<_Tp>' and 'll' {aka 'long long int'}
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/10/complex:456:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&)'
  456 |     operator-(const complex<_Tp>& __x)
      |     ^~~~~~~~
/usr/include/c++/10/complex:456:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::complex<_Tp>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)'
  406 |     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:406:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  406 |     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:406:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  406 |     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:406:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'll' {aka 'long long int'}
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)'
  406 |     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:406:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  406 |     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:406:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'll' {aka 'long long int'}
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/valarray:1186:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const std::valarray<_Tp>&, const std::valarray<_Tp>&)'
 1186 | _DEFINE_BINARY_OPERATOR(-, __minus)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1186:1: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/valarray:1186:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const std::valarray<_Tp>&, const typename std::valarray<_Tp>::value_type&)'
 1186 | _DEFINE_BINARY_OPERATOR(-, __minus)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1186:1: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from aliens.cpp:1:
/usr/include/c++/10/valarray:1186:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename std::valarray<_Tp>::value_type&, const std::valarray<_Tp>&)'
 1186 | _DEFINE_BINARY_OPERATOR(-, __minus)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1186:1: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   mismatched types 'const std::valarray<_Tp>' and 'll' {aka 'long long int'}
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1164:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)'
 1164 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1164:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1177:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)'
 1177 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1177:5: note:   template argument deduction/substitution failed:
aliens.cpp:61:32: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   61 |     return rv+(lv-rv)/(r-l)*(r-K);
      |                                ^