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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
using Bitset = bitset<10010>;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
Bitset knapsack;
knapsack[0] = -1;
vector<int> first_on(10010, -2);
for (int j = 0; j < n; j++) {
int v = w[j];
Bitset new_knapsack = knapsack | (knapsack << v);
Bitset tmp = new_knapsack ^ knapsack;
while (tmp.any()) {
int i = tmp._Find_first();
first_on[i] = j;
tmp[i] = 0;
}
knapsack = new_knapsack;
}
for (int i = l; i <= u; i++) {
if (first_on[i] != -2) {
vector<int> ans;
for (int j = first_on[i]; i != 0; j = first_on[i]) {
ans.push_back(j);
i -= w[j];
}
return ans;
}
}
return vector<int>();
}
# | 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... |