Submission #138284

#TimeUsernameProblemLanguageResultExecution timeMemory
138284arthurconmyDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #ifndef ARTHUR_LOCAL #include "molecules.h" #endif using namespace std; vector<int> find_subset(int l, int u, vector<int> W) { vector<int> use; int cur = 0; for(int i=0; i<W.size(); i++) { int w = W[i]; if(w>=l && w<=u) { return {w}; } if(w<l) { use.push_back(i); cur += w; if(cur > u) break; } } while(cur>u) { if(use.empty()) return {}; cur -= W[use.back()]; use.pop_back(); } if(use.empty() || !(cur>=l) || !(cur<=r)) return {}; else return use; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<W.size(); i++)
                  ~^~~~~~~~~
molecules.cpp:37:43: error: 'r' was not declared in this scope
     if(use.empty() || !(cur>=l) || !(cur<=r)) return {};
                                           ^
molecules.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^