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;
const int N = 5e5 + 5;
std::vector<int> find_subset(int l, int r, std::vector<int> w) {
int n = w.size();
bitset<N> old;
old.set(0, true);
vector<int> dp(N, -1);
if (*min_element(w.begin(), w.end()) > r) return {};
if (accumulate(w.begin(), w.end(), 0ll) < l) return {};
for (int i = 0; i < n; i++) {
bitset<N> nw = old | (old << w[i]);
bitset<N> shit = old ^ nw;
old = nw;
int x = shit._Find_first();
while (x < N) {
dp[x] = i;
shit.set(x, false);
x = shit._Find_next(x);
}
}
int x = -1;
for (int i = l; i <= r and x == -1; i++) if (old[i]) x = i;
assert(x != -1);
// if (x == -1) return {};
vector<int> ans;
while (x > 0) {
ans.emplace_back(dp[x]);
x -= w[dp[x]];
}
sort(ans.begin(), ans.end());
return ans;
}
# | 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... |