Submission #1219449

#TimeUsernameProblemLanguageResultExecution timeMemory
1219449AMel0nDetecting Molecules (IOI16_molecules)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #include "molecules.h" vector<int> find_subset(int l, int u, vector<int> W) { // bitset<32> dp; vector<pair<bool, int>> dp(u+1); dp[0].F = 1; vector<int> res; // bitset<200000> res; // int backtrack = 0; pair<bool,int> yes = {0,0}; FOR(i, W.size()) { for(int w = u; w >= 0; w--) { if (w != 0 && w-W[i] >= 0) { if (dp[w-W[i]].F) { dp[w] = {(dp[w-W[i]].F == 1), i}; } } // cout << i << ' ' << w<< ' '<<dp[w] << ' ' << W[i] << endl; if (l <= w && w <= u && dp[w].F) { yes = {1, w}; break; } } if (yes.F) break; } if (!yes.F) return res; while(yes.S != 0) { // cout << yes.S << ' '<<dp[yes.S].S << ' ' << W[dp[yes.S].S] <<endl; res.push_back(dp[yes.S].S); yes.S = yes.S - W[dp[yes.S].S]; } return res; }

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