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 <iostream>
#include <vector>
#include <bitset>
#include <cassert>
using namespace std;
typedef bitset<21> BS;
typedef vector<int> VI;
typedef vector<VI> VVI;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
const int N = w.size();
// assert(N <= 100 && u <= 1000);
BS can;
can[0] = true;
for (int n = 0; n < N; ++n) {
can |= can << w[n];
}
for (int sum = l; sum <= u; ++sum) {
if (can[sum]) {
vector<int> res;
for (int s = sum, n = N-1; s != 0; --n) {
assert(n >= 0);
if (s - w[n] >= 0 && can[s - w[n]]) {
res.push_back(n);
s -= w[n];
}
}
return res;
}
}
return {};
}
# | 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... |