#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
// inline void setup()
// {
// #ifndef ONLINE_JUDGE
// freopen("test.inp", "r", stdin);
// freopen("test.out", "w", stdout);
// #endif
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// }
vector<int> find_subset(int l, int u, vector<int> w)
{
queue<int> q;
vector<int> res, p[w.size()];
int sum = 0, x = -1;
for (int i = 0; i < w.size(); ++i)
{
p[i].resize(u + 1);
for (int j = 0; j <= u; ++j)
{
p[i][j] = (i == 0 ? -1 : p[i - 1][j]);
}
for (int j = u; j >= w[i]; --j)
{
if (p[i][j - w[i]] != -1 || j == w[i])
{
p[i][j] = i;
if (l <= j && x == -1)
{
x = j;
}
}
}
}
for (int i = w.size() - 1, j; i >= 0 && x > 0;)
{
j = p[i][x];
res.push_back(p[i][x]);
while (0 <= i && p[i][x] == res.back())
{
i--;
}
x -= w[res.back()];
}
reverse(res.begin(), res.end());
return res;
}
// int main()
// {
// setup();
// int n, u, l;
// vector<int> v;
// cin >> n >> l >> u;
// v.resize(n);
// for (int i = 0; i < n; ++i)
// {
// cin >> v[i];
// }
// v = find_subset(l, u, v);
// for (auto & i : v)
// {
// cout << i << " ";
// }
// return 0;
// }
Compilation message (stderr)
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |