# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024943 | 0npata | Detecting Molecules (IOI16_molecules) | C++17 | 317 ms | 4844 KiB |
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;
#define vec vector
const int MX = 500'005;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
//cat cerr << "ran" << '\n';
vec<int> seq(MX, -1);
int n = w.size();
bitset<MX> pos;
pos.set(0);
for(int i = 0; i<w.size(); i++) {
bitset<MX> npos = pos | (pos<<w[i]);
bitset<MX> nset = npos & (~pos);
for(int j = nset._Find_first(); j<MX; j=nset._Find_next(j)) {
seq[j] = i;
//cerr << "stuck1" << '\n';
}
//cerr << "slow" << '\n';
pos = npos;
}
int lst = -1;
for(int i = l; i<=u; i++) {
if(seq[i] != -1) lst = i;
}
if(lst == -1) {
return {};
}
vec<int> ans(0);
while(lst != 0) {
assert(seq[lst] != -1);
ans.push_back(seq[lst]);
lst -= w[seq[lst]];
}
reverse(ans.begin(), ans.end());
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... |