Submission #375744

#TimeUsernameProblemLanguageResultExecution timeMemory
375744OzyDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms364 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define lli int #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define debug(a) cout << #a << " = " << a << endl #define num first #define id second lli ult,sum,cont,n; lli visitados[200002]; vector<lli> res; vector<pair<lli,lli> > orden; vector<int> procesa(){ rep(i,0,n-1) if (visitados[i] > 0) res.push_back(i); return res; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { cont = 0; for (auto act : w) { orden.push_back({act,cont}); cont++; } sort(orden.begin(), orden.end()); ult = -1; cont = 0; sum = 0; n = w.size(); for (auto act : orden) { sum += act.num; if (sum > u) { ult = cont-1; sum -= act.num; break; } visitados[act.id] = 1; cont++; } if (sum <= u && sum >= l) procesa(); if (ult == -1) return {}; cont = ult; repa(i,n-1,n-cont-1) { sum -= orden[ult].num; visitados[ orden[ult].id ] = 0; sum += orden[i].num; visitados[ orden[i].id ] = 1; ult--; if (sum <= u && sum >= l) return procesa(); } return {}; }
#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...