Submission #133919

#TimeUsernameProblemLanguageResultExecution timeMemory
133919stoyan_malininDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include "grader.cpp" #include<random> #include <algorithm> using namespace std; mt19937 rnd(69420); vector<int> find_subset(int l, int u, vector<int> w) { sort(w.begin(), w.end()); long long sum = 0; for(int i = 0;i<w.size();i++) { sum += w[i]; } if(sum<l) return vector <int>{}; if(u<w[0]) return vector <int>{}; vector <int> answer; vector <pair <int, int>> v; for(int i = 0;i<w.size();i++) { v.push_back({w[i], i}); } int tries = 0; while(true) { tries++; if(tries>1000) break; sum = 0; shuffle(v.begin(), v.end(), rnd); for(int i = 0;i<v.size();i++) { sum += v[i].first; if(sum>=l && sum<=u) { for(int j = 0;j<=i;j++) { answer.push_back(v[j].second); } return answer; } if(sum>u) { break; } } } return vector<int>{}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<w.size();i++)
                   ~^~~~~~~~~
molecules.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<w.size();i++)
                   ~^~~~~~~~~
molecules.cpp:42:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i<v.size();i++)
                       ~^~~~~~~~~
/tmp/ccw7Y7ev.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccMBgbQZ.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status