Submission #1129387

#TimeUsernameProblemLanguageResultExecution timeMemory
1129387NAMINDetecting Molecules (IOI16_molecules)C++20
0 / 100
29 ms328 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<bool> take; pair<vector<int>,bool> solve(int l,int u,vector<pair<int,int>>& W){ if(l <= 0) return {{},true}; vector<int> ans; bool ok = false; for(int i=0;i<W.size();i++){ if(W[i].first > u || take[i]) continue; take[i] = true; auto res = solve(l-W[i].first,u-W[i].first,W); ans = res.first; ans.push_back(W[i].second); ok = res.second; if(ok){ break; } take[i] = false; } return {ans,ok}; } vector<int> find_subset(int l, int u,vector<int> w) { take.assign(w.size(),false); vector<pair<int,int>> W; for(int i=0;i<w.size();i++){ W.push_back(make_pair(w[i],i)); } sort(W.begin(),W.end()); return solve(l,u,W).first; }

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