# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434415 | OttoTheDino | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
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;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vll;
vi find_subset(int l, int u, vi w) {
bool dp[2][u+1] = {};
vi dpc[2][u+1] = {};
dp[1][0] = 1;
rep (i,0,(int)w.size()-1) {
rep (j,0,u) {
dp[i%2][u] = 0;
dpc[i%2][u].clear();
}
rep (j,1,u) {
if (j-w[i]>=0 && dp[(i%2)^1][j-w[i]]) {
dpc[i%2][j].pb(i);
dp[i%2][j] = 1;
}
}
}
rep (i,l,u) if (dp[((int)w.size()%2)^1][i]) return dpc[((int)w.size()%2)^1][i];
return vector<int>();
}