Submission #425360

#TimeUsernameProblemLanguageResultExecution timeMemory
425360dreezyDetecting Molecules (IOI16_molecules)C++17
9 / 100
5 ms588 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define pb push_back #define pi pair<int,int> #define ll long long #define mp make_pair vector<int> find_subset(int l, int u, vector<int> ww) { int n = ww.size(); vector<ll> w(n); for(int i =0; i<n ;i++) w[i] = ww[i]; set<pair<int, pair<int,int>>> pos;//val, w, ind set<int> nums; int num_ans = -1; vector<int> ans; for(int i = 0; i<n; i++){ //if( cursum + weights[i].w > u) continue; if(w[i] >=l && w[i] <= u){ return vector<int>(1, i); } set<int> ins; bool won = false; for(pair<int,pair<int,int>> val : pos){ int num = val.first; if(num + w[i] >= l && num+w[i] <= u){ num_ans = num; ans.pb(i); won = true; break; } if(num + w[i] < l ){ ins.insert(num+w[i]); } } if(won ) break; if(nums.find(w[i])== nums.end()) pos.insert({w[i], {w[i], i}}); for(int val : ins){ if(nums.find(val)== nums.end()) pos.insert({val, {w[i], i}}); } } if(num_ans == -1) return vector<int>(); while(num_ans != 0){ pair<int, pi> val = *lower_bound(pos.begin(), pos.end(), mp(num_ans, mp(-1, -1))); ans.pb(val.second.second); num_ans = num_ans - val.second.first; } 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...