# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209107 | my99n | Detecting Molecules (IOI16_molecules) | C++14 | 5 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#include "molecules.h"
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ans;
vector<pair<int,int>> s;
for (int i = 0; i < w.size(); i++) s.push_back({w[i], i});
sort(s.begin(), s.end());
int wmax = (s.end()-1)->first, wmin = s.begin()->first;
if (wmin > u) return vector<int>(0);
if (l <= wmin and wmin <= u) return vector<int>(1, s[0].second);
if (l <= wmax and wmax <= u) return vector<int>(1, s.back().second);
// cerr << "fuck god" << endl;
// case min <= max < l <= u
map<int,int> m;
int n = w.size();
queue<pair<int,int>> pre;
m[0] = -1;
for (int i = 0; i < n; i++) {
for (auto j : m) {
int key = j.first + w[i];
pre.push({key, i});
// cerr << key << endl;
if (l <= key and key <= u) {
// ans found;
ans.push_back(i);
key -= w[i];
while (key != 0) {
ans.push_back(m[key]);
key -= w[m[key]];
}
return ans;
}
}
while(!pre.empty()) {
m[pre.front().first] = pre.front().second;
pre.pop();
}
}
return vector<int>(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |