#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<bool> take;
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> find_subset(int l, int u,vector<int> w) {
take.assign(w.size(),false);
vector<pair<int,int>> W;
for(int i=0;i<w.size();i++){
W.push_back(make_pair(w[i],i));
}
sort(W.begin(),W.end());
return solve(l,u,W).first;
}
컴파일 시 표준 에러 (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... |