| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1129404 | NAMIN | Detecting Molecules (IOI16_molecules) | C++20 | 1095 ms | 580 KiB |
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
/*pair<vector<int>,bool> solve(int l,int u,vector<pair<int,int>>& W){
if(l <= 0)
return {{},true};
vector<int> ans;
bool ok = false;
for(int i=0;i<W.size();i++){
if(W[i].first > u || take[i])
continue;
take[i] = true;
auto res = solve(l-W[i].first,u-W[i].first,W);
ans = res.first;
ans.push_back(W[i].second);
ok = res.second;
if(ok){
break;
}
else
ans = vector<int>();
take[i] = false;
}
return {ans,ok};
}*/
vector<int> solve(int l,int u,vector<int>& w){
vector<bool> dp(1e6+1,false);
dp[0] = true;
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]] = true;
}
}
}
vector<int> ans;
for(int i=l;i<=u;i++){
if(dp[i]){
vector<int> take(n,false);
for(int j=0;j<n;j++){
if(i-w[j] >= 0){
if(dp[i-w[j]] && !take[j]){
ans.push_back(j);
take[j] = true;
i-=w[j];
j = 0;
}
}
}
break;
}
}
return ans;
}
vector<int> find_subset(int l, int u,vector<int> w) {
return solve(l,u,w);
}
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... | ||||
