Submission #1114566

# Submission time Handle Problem Language Result Execution time Memory
1114566 2024-11-19T08:05:50 Z lftroq Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<int> ans;
    int s=0;
    for(int i=0;i<(int)w.size();i++) if(s+w[i]<=u)
    {
        s+=w[i];
        ans.push_back(i);
    }
    if(s>=l) return ans;
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:4:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    4 |     vector<int> ans;
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
molecules.cpp:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> ans;
      |            ^~~
molecules.cpp:9:9: error: 'ans' was not declared in this scope
    9 |         ans.push_back(i);
      |         ^~~
molecules.cpp:11:21: error: 'ans' was not declared in this scope
   11 |     if(s>=l) return ans;
      |                     ^~~