Submission #1319225

#TimeUsernameProblemLanguageResultExecution timeMemory
1319225yessimkhanDetecting Molecules (IOI16_molecules)C++20
0 / 100
1 ms332 KiB
#include "molecules.h"
#include <bits/stdc++.h>
// solved by bekagg
#define ll long long
#define ent '\n'
#define pb push_back
#define all(x) x.begin(),x.end()
#define PRaim_bek_abi ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

const int N = 1e5+5;
const int MOD = 1e9+7;

int p[N];

vector<int> find_subset(int l, int u, vector<int> w){

    p[0] = -1;

    for (int i = 0; i < w.size(); i++){
        for (int j = u; j >= w[i]; j--){
            if (p[j] != 0 or p[j - w[i]] == 0){
                continue;
            }
            p[j] = i;
        }
    }

    for (int i = l; i <= u; i++){
        if (p[i] != 0){
            vector<int>ans;
            int x = i;
            while(x){
                ans.pb(p[x] + 1);
                x -= w[p[x]];
            }
            sort(all(ans));
            return ans;
        }
    }

    return {0};

}

Compilation message (stderr)

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...