Submission #366725

#TimeUsernameProblemLanguageResultExecution timeMemory
366725BartolMDetecting Molecules (IOI16_molecules)C++17
31 / 100
65 ms65540 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; const int INF=0x3f3f3f3f; const int N=10003; const int MAX=5e5+2; int n; bitset <MAX> dp[N]; vector <int> sol; vector<int> find_subset(int l, int u, vector<int> w) { dp[0][0]=1; n=w.size(); for (int i=1; i<=n; ++i) { int x=w[i-1]; dp[i]=dp[i-1]<<x; dp[i]|=dp[i-1]; } int res=-1; for (int i=l; i<=u; ++i) { if (dp[n][i]) { res=i; break; } } if (res==-1) return sol; pii pp=mp(n, res); while (pp.Y) { int x=w[pp.X-1]; if (dp[pp.X-1][pp.Y]) pp.X--; else pp.X--, pp.Y-=x, sol.pb(pp.X); } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...