#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef tuple <ll,ll,ll> plll;
typedef vector <plll> vplll;
typedef pair <ll,ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <vector <pll>> vvpll;
typedef vector <vector <ll>> vvll;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;
#define loop(i, s, e) for (ll i = (s); i < (e); ++i)
#define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i)
#define all(a) a.begin(), a.end()
const ll inf = 1e9 + 7;
std::vector<int> find_subset(int l, int r, std::vector<int> w) {
ll n = w.size();
ll maxi =r+1;
// vector<pair<ll, vll>> dp(maxi,{0,{}} );
map<ll,pair<ll,vll>> dp;
dp[0].first = 1;
dp[0].second.resize(n,0);
// n*maxi
loop(i,1,maxi) {// maxi =r <=1e4
loop(j,0,n) { //n<=1e4
ll num = w[j];
if (i-num>=0 && dp.count(i-num) && dp[i-num].first == 1 && dp[i-num].second[j]==0) {
dp[i].first = 1;
dp[i].second = dp[i-num].second;
dp[i].second[j] = 1;
}
}
if (i>=l && i<=r && dp.count(i)) {
vector<int> ansi;
loop(c,0,n) if (dp[i].second[c]== 1) ansi.push_back(c);
return ansi;
}
}
return {};
}
Compilation message (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... |