Submission #348976

#TimeUsernameProblemLanguageResultExecution timeMemory
348976IwanttobreakfreeDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include "molecules.h" using namespace std; vector <int> find_subset(int l,int u,vector <int>& w ){ vector <int> res; int suma,contador; for(int a=0;a<w.size();a++){ if(w[a]<=u&&w[a]>=l){ res[0]=w[a]; return res; } else if(w[a]>u) w.erase(w.begin()+a); } sort(w.rbegin(),w.rend()); while (suma<l||suma>u){ if(suma<l) { suma+=w[contador]; res[contador]=w[contador],contador++; } else if(suma>u) { suma-=w[contador]; res.erase(res.begin()+contador),contador--; } } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>&)':
molecules.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int a=0;a<w.size();a++){
      |              ~^~~~~~~~~
molecules.cpp:21:20: warning: 'contador' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |    suma+=w[contador];
      |                    ^
molecules.cpp:25:7: warning: 'suma' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   suma-=w[contador];
/tmp/ccLwbint.o: In function `main':
grader.cpp:(.text.startup+0x139): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status