Submission #380678

#TimeUsernameProblemLanguageResultExecution timeMemory
380678madlogicDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> res; int n = (int) w.size(); for (int i = 0; i < n; i++) { if (w[i] >= l && w[i] <= u) { return {i}; } } vector<pair<int, int>> nums; for (int i = 0; i < n; i++) { if (w[i] <= u) { nums.emplace_back(w[i], i); } } sort(nums.rbegin(), nums.rend()); int cur = 0; vector<int> res; for (auto& [x, y] : nums) { if (cur + x > u) { continue; } cur += x; res.push_back(y); } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> res;
      |   ^~~~~~
molecules.cpp:4:3: note: suggested alternatives:
In file included from /usr/include/c++/9/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note:   'std::vector'
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/vector:90:13: note:   'std::pmr::vector'
   90 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
molecules.cpp:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> res;
      |          ^~~
molecules.cpp:11:10: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   11 |   vector<pair<int, int>> nums;
      |          ^~~~
      |          std::pair
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_pair.h:208:12: note: 'std::pair' declared here
  208 |     struct pair
      |            ^~~~
molecules.cpp:11:15: error: expected primary-expression before 'int'
   11 |   vector<pair<int, int>> nums;
      |               ^~~
molecules.cpp:14:7: error: 'nums' was not declared in this scope
   14 |       nums.emplace_back(w[i], i);
      |       ^~~~
molecules.cpp:17:8: error: 'nums' was not declared in this scope
   17 |   sort(nums.rbegin(), nums.rend());
      |        ^~~~
molecules.cpp:17:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |   sort(nums.rbegin(), nums.rend());
      |   ^~~~
      |   short
molecules.cpp:19:10: error: expected primary-expression before 'int'
   19 |   vector<int> res;
      |          ^~~
molecules.cpp:25:5: error: 'res' was not declared in this scope
   25 |     res.push_back(y);
      |     ^~~
molecules.cpp:27:10: error: 'res' was not declared in this scope
   27 |   return res;
      |          ^~~