Submission #867168

#TimeUsernameProblemLanguageResultExecution timeMemory
867168StefanL2005Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <set> using namespace std; #define ll long long int find_subset(int l, int u, vector<int> w, int n, vector<int> &result) { set<int> Set; sort(w.begin(), w.end()); if(l < w[0]) return 0; if (l - u < w[n-1] - w[0]) return 0; ll sum = 0; int i = 0; for (i; i < n; i++) { if (sum + w[i] > l) break; sum+= w[i]; Set.insert(w[i]); } int dif = l - sum; while (i < n && !(u <= sum && sum <= l)) { auto poz = Set.lower_bound(w[i] - dif); if (poz == Set.end()) break; sum= sum - *poz + w[i]; Set.erase(poz); Set.insert(w[i]); i++; } if (u <= sum && sum <= l) { auto p = Set.begin(); for(i = 0; i < n; i++) if (w[i] == *p) { result.push_back(i); Set.erase(p); p = Set.begin(); } } return result.size(); }

Compilation message (stderr)

molecules.cpp: In function 'int find_subset(int, int, std::vector<int>, int, std::vector<int>&)':
molecules.cpp:22:10: warning: statement has no effect [-Wunused-value]
   22 |     for (i; i < n; i++)
      |          ^
/usr/bin/ld: /tmp/cckswwRJ.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