Submission #341157

#TimeUsernameProblemLanguageResultExecution timeMemory
341157YJUDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include"molecules.h" #pragma GCC optimize("unroll-loops,no-stack-protector") using namespace std; typedef int ll; typedef long double ld; typedef pair<ll,ll> pll; const ll MOD=1e9+7; const ll MOD2=998244353; const ll N=5e3+7; const ll K=350; const ld pi=acos(-1); const ll INF=(1LL<<60); #define SQ(i) ((i)*(i)) #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(_a) (ll)_a.size() vector<ll> find_subset(ll l,ll r,vector<ll> w){ vector<ll> lis; REP(i,SZ(w))lis.pb(i); sort(lis.begin(),lis.end(),[](ll a,ll b){ return (w[a]<w[b]); }); ll sum=0; vector<ll> ans; REP(i,SZ(lis)){ sum+=w[lis[i]]; ans.pb(lis[i]); if(sum>=l&&sum<=r){ return ans; }else if(sum>r){ sum-=w[ans[0]]; ans.erase(ans.begin(),next(ans.begin())); return ans; } } return 0; }

Compilation message (stderr)

molecules.cpp:13:18: warning: overflow in conversion from 'long long int' to 'll' {aka 'int'} changes value from '1152921504606846976' to '0' [-Woverflow]
   13 | const ll INF=(1LL<<60);
      |              ~~~~^~~~~
molecules.cpp: In lambda function:
molecules.cpp:29:11: error: 'w' is not captured
   29 |   return (w[a]<w[b]);
      |           ^
molecules.cpp:28:30: note: the lambda has no capture-default
   28 |  sort(lis.begin(),lis.end(),[](ll a,ll b){
      |                              ^
molecules.cpp:25:45: note: 'std::vector<int> w' declared here
   25 | vector<ll> find_subset(ll l,ll r,vector<ll> w){
      |                                  ~~~~~~~~~~~^
molecules.cpp:29:16: error: 'w' is not captured
   29 |   return (w[a]<w[b]);
      |                ^
molecules.cpp:28:30: note: the lambda has no capture-default
   28 |  sort(lis.begin(),lis.end(),[](ll a,ll b){
      |                              ^
molecules.cpp:25:45: note: 'std::vector<int> w' declared here
   25 | vector<ll> find_subset(ll l,ll r,vector<ll> w){
      |                                  ~~~~~~~~~~~^
molecules.cpp: In function 'std::vector<int> find_subset(ll, ll, std::vector<int>)':
molecules.cpp:44:9: error: could not convert '0' from 'int' to 'std::vector<int>'
   44 |  return 0;
      |         ^
      |         |
      |         int
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Iterator2 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)>]':
/usr/include/c++/9/bits/stl_algo.h:81:17:   required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1920:34:   required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1952:38:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1967:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)>]'
molecules.cpp:30:3:   required from here
/usr/include/c++/9/bits/predefined_ops.h:143:18: error: void value not ignored as it ought to be
  143 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = int; _Iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)>]':
/usr/include/c++/9/bits/stl_algo.h:1827:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1854:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1884:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1970:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)>]'
molecules.cpp:30:3:   required from here
/usr/include/c++/9/bits/predefined_ops.h:215:11: error: void value not ignored as it ought to be
  215 |  { return bool(_M_comp(__val, *__it)); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Value = int; _Compare = find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)>]':
/usr/include/c++/9/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Distance = long int; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_comp_val<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_heap.h:237:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Distance = long int; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_heap.h:342:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1671:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1932:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1947:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:1967:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)> >]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = find_subset(ll, ll, std::vector<int>)::<lambda(ll, ll)>]'
molecules.cpp:30:3:   required from here
/usr/include/c++/9/bits/predefined_ops.h:177:11: error: void value not ignored as it ought to be
  177 |  { return bool(_M_comp(*__it, __val)); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~