#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> ans;
vector<pair<int,int>> v;
stack<int> s;
int che;
int l,u,n;
void f(int idx,int sumi){
if(idx!=n+1)
s.push({v[idx].second});
if(sumi>=l)
che=1;
if(che==1)
return;
int z=upper_bound(v.begin(),v.end(),make_pair(u-sumi,INT_MAX))-v.begin();
if(z==0){
return;
}
for(int i=min(z-1,idx-1);i>=0;i--){
f(i,sumi+v[i].first);
if(che==1)
return;
s.pop();
}
}
vector<int> find_subset(int ll, int uu, vector<int> w) {
n=w.size();
l=ll;
u=uu;
for(int i=0;i<n;i++){
v.push_back({w[i],i});
}
v.push_back({INT_MAX,0});
sort(v.begin(),v.end());
f(n+1,0);
while(s.empty()==0){
ans.push_back(s.top());
s.pop();
}
return ans;
}
컴파일 시 표준 에러 (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... |