Submission #1138165

#TimeUsernameProblemLanguageResultExecution timeMemory
1138165AliyyiakbarDetecting Molecules (IOI16_molecules)C++20
31 / 100
1092 ms472 KiB
#include "molecules.h" #include "bits/stdc++.h" using namespace std; const int sz = 5e5 + 9; const int N = 10001; vector<int> find_subset(int l, int r, vector<int> w) { bitset<sz> dp; dp[0] = 1; int n = w.size(); for (int i = 0; i < n; ++i) { for (int j = 5e5; j >= 0; --j) { if (j + w[i] <= 5e5 && dp[j]) { dp[j + w[i]] = 1; } } } vector<int> ans; for(int i = l; i <= r; ++i) { if (dp[i]) { bitset<N> take; for (int j = 0; j < n; ++j) { if (i - w[j] >= 0 && dp[i - w[j]] && take[j] == 0) { ans.push_back(j); take[j] = 1; i -= w[j]; j = 0; } } return ans; } } return {}; }

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