Submission #655034

#TimeUsernameProblemLanguageResultExecution timeMemory
655034benjaminkleynDetecting Molecules (IOI16_molecules)C++17
19 / 100
202 ms65536 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int max_n = 100000;

vector<int> find_subset(int l, int u, vector<int> w)
{
    int n = w.size();
    map<ll, bitset<max_n>> subsets;
    subsets[0] = bitset<max_n>(0);
    for (int i = 0; i < n; i++)
    {
        vector<pair<ll, bitset<max_n>>> new_subsets;
        for (auto [sum, subset] : subsets)
        {
            subset[i] = 1;
            new_subsets.push_back({sum + w[i], subset});
        }
        for (auto [sum, subset] : new_subsets)
        {
            subsets[sum] = subset;
            if (l <= sum && sum <= u)
            {
                vector<int> res;
                for (int j = 0; j <= i; j++)
                    if (subset[j])
                        res.push_back(j);
                return res;
            }
        }
    }
    return vector<int>(0,0);
}
#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...