| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1247047 | julia_08 | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 328 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 1e4 + 10;
int dp[MAXN];
vector<int> solve(int l, int u, vector<pair<int, int>> &W){
ll sum = 0;
vector<int> ans;
for(int i=0; i<W.size(); i++){
sum += W[i].first;
if(l <= sum && sum <= u){
for(int j=0; j<=i; j++) ans.push_back(W[j].second);
return ans;
}
if(sum > u){
if(l <= sum - W[0].first && sum - W[0].first <= u){
for(int j=1; j<=i; j++) ans.push_back(W[j].second);
return ans;
}
}
}
return {};
}
vector<int> find_subset(int l, int u, vector<int> w){
if(l > u) return {};
vector<pair<int, int>> W;
for(int i=0; i<w.size(); i++) W.push_back({w[i], i});
sort(W.begin(), W.end());
if(W[0].first > u) return {};
for(auto x : W){
if(l <= x.first && x.first <= u){
return {x.second};
}
}
if(W[0].first <= u - l) return solve(l, u, W);
dp[0] = 1;
for(int i=1; i<=W.size(); i++){
auto [x, j] = W[i - 1];
for(int k=u; k>=x; k--){
if(dp[k - x] != 0){
dp[k] = i;
}
}
}
for(int i=l; i<=u; i++){
if(dp[i]){
vector<int> ans;
int val = i;
for(int j=W.size(); j>=1; j--){
if(W[j - 1].first <= val && dp[val] == j){
ans.push_back(W[j - 1].second);
val -= W[j - 1].first;
}
}
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... | ||||
