Submission #717723

#TimeUsernameProblemLanguageResultExecution timeMemory
717723ToxtaqDetecting Molecules (IOI16_molecules)C++17
46 / 100
1072 ms2388 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int r, vector<int>w){ int n = w.size(); bitset<500001>table; vector<int>par(r + 1, -1); table[0] = 1; for(int i = 0;i < n;++i){ for(int j = r;j >= 1;--j){ if(table[j] || j - w[i] < 0)continue; if(table[j - w[i]]){ table[j] = 1; par[j] = i; } } } int num = -1; for(int i = l;i <= r;++i){ if(table[i]){ num = i; break; } } vector<int>ans; if(num < 0)return ans; while(par[num] != -1){ ans.push_back(par[num]); num -= w[par[num]]; } return ans; } //int main() //{ // int l, r, n; // cin >> l >> r >> n; // vector<int>v(n); // for(int i = 0;i < n;++i)cin >> v[i]; // vector<int>ans = find_subset(l, r, v); // for(int i : ans)cout << 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...