Submission #1198371

#TimeUsernameProblemLanguageResultExecution timeMemory
1198371grafffDetecting Molecules (IOI16_molecules)C++20
0 / 100
0 ms328 KiB
#ifdef molecules.h
#include "molecules.h"
#endif

#include <bits/stdc++.h>

using namespace std;

vector <int> find_subset(int l, int u, vector <int> w){
    int n = w.size(), res = 0;
    unordered_map <int, int> mp;
    vector <int> st = {0};
    mp[0] = -1;
    bool flag = false;
    for(int i = 0; i < n; i++){
        int k = st.size();
        for(int j = 0; j < k; j++){
            int x = st[j] + w[i];
            if(mp[x] == 0 && w[0] != x){
                mp[x] = i;
                st.push_back(x);
            }
            if(l <= x && x <= u){
                flag = true;
                res = x;
                break;
            }
        }
        if(flag){
            break;
        }
    }
    vector <int> ans;
    int x = mp[res];
    while(x >= 0){
        ans.push_back(x);
        res -= w[x];
        x = mp[res];
    }
    return ans;
}

Compilation message (stderr)

molecules.cpp:1:17: warning: extra tokens at end of #ifdef directive
    1 | #ifdef molecules.h
      |                 ^
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...