Submission #1078393

#TimeUsernameProblemLanguageResultExecution timeMemory
1078393DrAymeinsteinDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; static vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int, int>> vec; // vec = <weight, index> for (int i = 0; i < n; i++) { vec.push_back({ w[i], i }); } sort(vec.begin(), vec.end()); // based on w[i] int left = 0, right = 0; // pointers (hash map maybe) long long sum = vec[0].first; while (right < n) { if (sum >= l && sum <= u) { vector<int> result; for (int i = left; i <= right; i++) { result.push_back(vec[i].second); } return result; } if (sum < 1 && right + 1 < n) { right++; sum += vec[right].first; } else if (sum > u && left < right) { sum -= vec[left].first; left++; } else { break; } } return {}; }

Compilation message (stderr)

molecules.cpp:8:20: warning: 'std::vector<int> find_subset(int, int, std::vector<int>)' defined but not used [-Wunused-function]
    8 | static vector<int> find_subset(int l, int u, vector<int> w) {
      |                    ^~~~~~~~~~~
/usr/bin/ld: /tmp/cclj0fI3.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status