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>
using namespace std;
vector<int>find_subset(int l, int r, vector<int> w) {
if(l > r) return {};
int n = w.size();
vector<vector<bool>>pd(n+1, vector<bool>(r));
for(int i=l; i<=r; i++) pd[n][i] = true;
for(int i=n-1; i>=0; i--) {
for(int j=0; j<=r; j++) {
pd[i][j] = pd[i+1][j];
if(j + w[i] <= r) pd[i][j] = (pd[i+1][j] || pd[i+1][j+w[i]]);
}
}
int i=0, j=0;
vector<int>res;
while(i<n) {
if(!pd[i][j]) return {};
if(pd[i][j] != pd[i+1][j]) {
res.push_back(i);
j += w[i];
}
i++;
}
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... |