# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1138164 | Aliyyiakbar | Detecting Molecules (IOI16_molecules) | C++20 | 1093 ms | 580 KiB |
#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
const int sz = 1e6 + 9;
const int N = 10001;
vector<int> find_subset(int l, int r, vector<int> w)
{
bitset<sz> dp;
dp[0] = 1;
int n = w.size();
for (int i = 0; i < n; ++i)
{
for (int j = 1e6; j >= 0; --j)
{
if (j + w[i] <= 1e6 && dp[j])
{
dp[j + w[i]] = 1;
}
}
}
vector<int> ans;
for(int i = l; i <= r; ++i)
{
if (dp[i])
{
bitset<N> take;
for (int j = 0; j < n; ++j)
{
if (i - w[j] >= 0 && dp[i - w[j]] && take[j] == 0)
{
ans.push_back(j);
take[j] = 1;
i -= w[j];
j = 0;
}
}
return ans;
}
}
return {};
}
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... |