Submission #725369

#TimeUsernameProblemLanguageResultExecution timeMemory
725369AndrijaMDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
vector<int>arr;
long long n;
long long dp[105][1005];
 
long long f(long long idx,long long x,vector<long long>vec,long long mx,vector<long long>weight)
{
    if(idx==n)
    {
        arr=vec;
        return 0;
    }
    if(dp[idx][x]!=-1)return dp[idx][x];
    long long rez=0;
    rez=max(rez, f(idx+1,x,vec,mx,weight));
    vector<long long>pom;
    pom=vec;
    pom.push_back(idx);
    if(x+weight[idx]<=mx)
    rez=max(rez, f(idx+1,x+weight[idx],pom,mx,weight)+weight[idx]);
    return dp[idx][x]=rez;
}
 
vector<int> find_subset(int l, int u, vector<int> w)
{
    memset(dp,-1,sizeof dp);
    vector<long long>v;
    queue<long long>Q;
    n=w.size();
    long long kol=f(0,0,v,u,w);
    if(kol<l)
    {
        return {};
    }
    return arr;
}

Compilation message (stderr)

molecules.cpp: In function 'long long int f(long long int, long long int, std::vector<long long int>, long long int, std::vector<long long int>)':
molecules.cpp:13:13: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   13 |         arr=vec;
      |             ^~~
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:33:29: error: could not convert 'w' from 'vector<int>' to 'vector<long long int>'
   33 |     long long kol=f(0,0,v,u,w);
      |                             ^
      |                             |
      |                             vector<int>