Submission #527002

#TimeUsernameProblemLanguageResultExecution timeMemory
527002lcs147Detecting Molecules (IOI16_molecules)C++98
0 / 100
1 ms296 KiB
#include"molecules.h" #include<bits/stdc++.h> using namespace std; vector<int>find_subset(int l, int r, vector<int> w) { if(l > r) return {}; vector<int>id(w.size()); iota(id.begin(), id.end(), 0); sort(id.begin(), id.end(), [&](int a, int b){ return w[a] < w[b]; }); while(id.size() && w[id.back()] > r) id.pop_back(); int sum = 0; vector<int>has_sum(r+1, -1); int en = -1; while(1) { if(sum != 0) { while(sum <= r && has_sum[sum]==-1) sum++; } if(sum > r) return {}; if(sum >= l) { en = sum; break; } for(int i = has_sum[sum]+1; i<id.size(); i++) { int nsum = sum + w[id[i]]; if(nsum > r) break; has_sum[nsum] = i; } sum++; } sum = en; vector<int>res; while(sum > 0) { int rid = id[has_sum[sum]]; res.push_back(rid); sum -= w[rid]; } sort(res.begin(), res.end()); return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:28:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i = has_sum[sum]+1; i<id.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...