Submission #133920

#TimeUsernameProblemLanguageResultExecution timeMemory
133920stoyan_malininDetecting Molecules (IOI16_molecules)C++14
9 / 100
4 ms380 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++)
                       ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...