Submission #1087834

#TimeUsernameProblemLanguageResultExecution timeMemory
1087834MahmytMDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back #define yes cout<<"YES"<<endl #define no cout<<"NO"<<endl#include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { int sum=0; vector<int> ans; for(int i=0;i<w.size();i++){ if(sum+w[i]<=u){ sum+=w[i]; ans.pb(i); } } if(l<=sum and sum<=u){ return ans; } return std::vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:5: error: 'vector' was not declared in this scope
   12 |     vector<int> ans;
      |     ^~~~~~
molecules.cpp:12:5: note: suggested alternatives:
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'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
molecules.cpp:12:12: error: expected primary-expression before 'int'
   12 |     vector<int> ans;
      |            ^~~
molecules.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:16:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |       ans.pb(i);
      |       ^~~
      |       abs
molecules.cpp:20:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |   return ans;
      |          ^~~
      |          abs