Submission #995434

#TimeUsernameProblemLanguageResultExecution timeMemory
995434The_SamuraiDetecting Molecules (IOI16_molecules)C++17
0 / 100
3 ms5032 KiB
#include "molecules.h" #include "bits/stdc++.h" using namespace std; const int N = 5e5 + 5; std::vector<int> find_subset(int l, int r, std::vector<int> w) { int n = w.size(); bitset<N> old; old.set(0, true); vector<int> dp(N, -1); if (*min_element(w.begin(), w.end()) > r) return {}; if (accumulate(w.begin(), w.end(), 0ll) < l) return {}; for (int i = 0; i < n; i++) { bitset<N> nw = old | (old << w[i]); bitset<N> shit = old ^ nw; old = nw; int x = shit._Find_first(); while (x < N) { dp[x] = i; shit.set(x, false); x = shit._Find_next(x); } } int x = -1; for (int i = l; i <= r and x == -1; i++) if (old[i]) x = i; assert(x != -1); if (x == -1) return {}; vector<int> ans; while (x > 0) { ans.emplace_back(dp[x]); x -= w[dp[x]]; } sort(ans.begin(), ans.end()); return ans; }
#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...