# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1211220 | madamadam3 | Detecting Molecules (IOI16_molecules) | C++20 | 8 ms | 328 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_SUM = 10'000;
using bset = bitset<MAX_SUM+1>;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<int> par(MAX_SUM + 1, -1);
bset possible;
possible.set(0);
for (int i = 0; i < n; i++) {
bset nw = (possible | (possible << w[i])) ^ possible;
possible |= (possible << w[i]);
size_t pos = nw._Find_first();
while (pos != nw.size()) {
par[pos] = i;
pos = nw._Find_next(pos);
}
}
// for (int i = 0; i <= u; i++) {
// cout << i << "\t";
// }
// cout << "\n";
// for (int i = 0; i <= u; i++) {
// cout << par[i] << "\t";
// }
// cout << "\n";
vector<int> ans;
int first_valid = 0;
for (int i = l; i <= u; i++) {
if (par[i] != -1) {
first_valid = i;
break;
}
}
while (first_valid != 0) {
ans.push_back(par[first_valid]);
first_valid = first_valid - w[par[first_valid]];
}
// for (auto &el : ans) {
// cout << el << " ";
// }
// cout << "\n";
return ans;
}
Compilation message (stderr)
# | 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... |