# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1197267 | andrejikus | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
const int N = 1e4 + 3;
const int inf = 1e9;
int dp[N];
vector<int> find_subset(int l, int u, vector<int> w) {
for (int i = 0; i < N; i++) dp[i] = inf;
vector<int> res;
dp[0] = 0;
for (int i = 0; i < w.size(); i++) {
for (int j = 0; j <= u; j++) {
if (j-w[i] < 0) continue;
if (dp[j-w[i]] == inf || dp[j-w[i]] == i+1) continue;
dp[j] = min(dp[j], i+1);
}
}
for (int t = l; t <= u; t++) {
if (dp[t] == -1) continue;
int j = t;
while (j != 0) {
res.push_back(dp[j]-1);
j -= w[dp[j]-1];
}
if (j == 0) break;
}
sort(res.begin(), res.end());
return res;
}
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... |