This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
#define debug printf
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define ll long long
#define sz size()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define tiii tuple<int,int,int>
#define mkt make_tuple
const int MAX = 10010 ;
using namespace std ;
bool dp[MAX][MAX] ;
vector<int> res ;
vector<int> find_subset(int l, int u, vector<int> w)
{
int cnt = 1 ;
dp[0][0] = true ;
for(int i : w)
{
for(int j = u ; j >= 0 ; j-- )
{
if( cnt-1 < 0 || cnt >= MAX || j >= MAX )
return vector<int>(0) ;
dp[cnt][j] = dp[cnt-1][j] ;
if( j + i <= u )
dp[cnt][j+i] |= dp[cnt-1][j] ;
}
cnt ++ ;
}
cnt -- ;
int ok = -1 ;
lp(i,l,u+1)
if( dp[cnt][i] ) ok = i ;
if( ok == -1 ) return res ;
for(int i = cnt ; i > 0 ; i-- )
if( w[i-1] <= ok && dp[i][ok] && dp[i-1][ok-w[i-1]] )
{
res.pb(i-1) ;
ok -= w[i-1] ;
}
sort(all(res));
return res ;
}
# | 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... |