This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(j - w[i] >= 0 && table[j - w[i]]){
table[j] = 1;
if(par[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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |