Submission #867407

#TimeUsernameProblemLanguageResultExecution timeMemory
867407cheat_when_I_was_youngDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int,int>> a; for (int i = 0; i < (int)w.size(); ++i) a.push_back({w[i], i}); sort(a.begin(), a.end()); queue<int> q; vector<int> ans; long long s = 0; for (int i = 0; i < (int)a.size(); ++i) { q.push(a[i].second); s += a[i].first; if (l <= s && s <= u) break; while (!q.empty() && s > u) { s -= w[q.front()]; q.pop(); } } if (s < l || s > u) return vector<int>(0); while (!q.empty()) { ans.push_back(q.front() + 1); q.pop(); } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |     sort(a.begin(), a.end());
      |     ^~~~
      |     short
molecules.cpp:10:5: error: 'queue' was not declared in this scope
   10 |     queue<int> q;
      |     ^~~~~
molecules.cpp:2:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    1 | #include "molecules.h"
  +++ |+#include <queue>
    2 | using namespace std;
molecules.cpp:10:11: error: expected primary-expression before 'int'
   10 |     queue<int> q;
      |           ^~~
molecules.cpp:16:9: error: 'q' was not declared in this scope
   16 |         q.push(a[i].second);
      |         ^
molecules.cpp:29:13: error: 'q' was not declared in this scope
   29 |     while (!q.empty()) {
      |             ^