Submission #526984

#TimeUsernameProblemLanguageResultExecution timeMemory
526984lcs147Detecting Molecules (IOI16_molecules)C++98
46 / 100
341 ms65540 KiB
#include"molecules.h" #include<bits/stdc++.h> using namespace std; vector<int>find_subset(int l, int r, vector<int> w) { if(l > r) return {}; int n = w.size(); vector<vector<bool>>pd(n+1, vector<bool>(r)); for(int i=l; i<=r; i++) pd[n][i] = true; for(int i=n-1; i>=0; i--) { for(int j=0; j<=r; j++) { pd[i][j] = pd[i+1][j]; if(j + w[i] <= r) pd[i][j] = (pd[i+1][j] || pd[i+1][j+w[i]]); } } int i=0, j=0; vector<int>res; while(i<n) { if(!pd[i][j]) return {}; if(pd[i][j] != pd[i+1][j]) { res.push_back(i); j += w[i]; } i++; } return res; }
#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...