| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1097911 | dzhoz0 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 348 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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> sub1(int l, int u, vector<int> w) {
    int n = w.size();
    int cur = 0;
    vector<int> res;
    for(int i = 0; i < n; i++) {
        cur += w[i];
        res.push_back(i);
        if(cur >= l && cur <= u) {
            return res;
        }
    }
    return vector<int>(0);
}
vector<int> sub123(int l, int u, vector<int> w) {
    int n = w.size();
    vector<pair<bool, int>> dp(u + 5, {false, -1});
    dp[0] = {true, -1};
    for(int i = 0; i < n; i++) {
        for(int x = u; x >= w[i]; x--) {
            if(dp[x - w[i]].first == true) {
                dp[x] = {true, i};
            }
        }
    }
    // for(int x = 0; x <= u; x++) {
    //     cout << x << ' ' << dp[x].first << '\n';
    // }
    for(int val = l; val <= u; val++) {
        if(dp[val].first == true) {
            int x = val;
            // cout << x << ' ' << dp[x].second << '\n';
            vector<int> res;
            int id = dp[x].second;
            
            while(id != -1) {
                res.push_back(id);
                // cout << id << '\n';
                x -= w[id];
                id = dp[x].second;
            }
            // cout << res.size() << '\n';
            return res;
        }
    }
    return vector<int>(0);
}
vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();
    // sort(w.begin(), w.end());
    int mx = *max_element(w.begin(), w.end()), mi = *min_element(w.begin(), w.end());
    if(u <= 1000) return sub123(l, u, w);
    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... | ||||
