#include <bits/stdc++.h>
#define ll long long
#define sz(x) int(x.size())
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
using namespace std;
vector<int> arm(vector<pair<int, int>> &dp, int j)
{
ll sig = j;
vector<int> ans;
while (sig >= 0)
{
if (dp[sig].se >= 0)
ans.pb(dp[sig].se);
sig = dp[sig].fr;
}
return ans;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
vector<int> ans;
if (l > u)
return ans;
vector<pair<ll, ll>> v;
ll i, j, ma=0, maI=0;
for (i = 0; i < sz(w); i++)
{
v.pb({w[i], i});
}
sort(all(v));
i=sz(v)-1;
while(i>=0&&l>v[i].fr*2)
{
l=l-v[i].fr;
u=u-v[i].fr;
ans.pb(v[i].se);
for(j=0; j<sz(v); j++)
{
if(l<=v[j].fr&&v[j].fr<=u)
return ans;
}
i--;
}
while(i+1<sz(v))
v.pop_back();
if(i<0)
{
ans.resize(0);
return ans;
}
vector<pair<int, int>> dp(u + 1);
vector<bool> pos(u + 1);
pos[0] = 1;
dp[0].fr = -1;
dp[0].se = -1;
for (i = 0; i < sz(v); i++)
{
ll x = v[i].fr;
int nod = v[i].se;
for (j = u; j >= x; j--)
{
if (pos[j])
continue;
if (pos[j - x])
{
pos[j] = 1;
dp[j].fr = j - x;
dp[j].se = nod;
if (j >= l)
{
vector<int>ret=arm(dp, j);
for(auto k:ret)
ans.pb(k);
return ans;
}
}
}
}
ans.resize(0);
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... |