Submission #589885

#TimeUsernameProblemLanguageResultExecution timeMemory
589885Sam_a17Detecting Molecules (IOI16_molecules)C++14
9 / 100
16 ms23792 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> // #include "molecules.h" #include <cstdio> using namespace std; #define ll long long const int M = 1e6 + 10, N = 1e6 + 10; int n; bool dp[M]; vector<int> bit[N]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { n = w.size(); vector<int> possible{0}; vector<int> answ; dp[0] = true; sort(w.begin(), w.end()); vector<pair<int, int>> vi; for(int i = 0; i < n; i++) { vi.push_back({w[i], i}); } sort(vi.begin(), vi.end()); for(int i = 0; i < n; i++) { vector<int> to_add; for(auto j: possible) { if(j + vi[i].first > u) { break;; } if(dp[j + w[i]]) { continue; } dp[j + vi[i].first] = true; to_add.push_back(j); } for(auto j: to_add) { bit[j + vi[i].first] = bit[j]; bit[j + vi[i].first].push_back(vi[i].second); if(j + vi[i].first >= l && j + vi[i].first <= u) { return bit[j + vi[i].first]; } possible.push_back(j + w[i]); } sort(possible.begin(), possible.end()); } return answ; }
#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...