제출 #794780

#제출 시각아이디문제언어결과실행 시간메모리
794780baneDetecting Molecules (IOI16_molecules)C++17
31 / 100
41 ms65536 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; int dp[10001][10001], pre[10001][10001]; vector<int> find_subset(int l, int u, vector<int> w) { int n = (int)w.size(); for (int i = 1; i <= n; i++){ for (int j = 0; j <= u; j++){ dp[i][j] = dp[i - 1][j]; pre[i][j] = pre[i - 1][j]; } if (w[i - 1] <= u){ dp[i][w[i - 1]] = i; if (w[i - 1] >= l){ return {i-1}; } pre[i][w[i - 1]] = (int)1e9; } if (w[i - 1] == 0)continue; if (w[i - 1] > u)continue; for (int j = 1; j + w[i-1] <= u; j++){ if (dp[i-1][j]){ dp[i][j + w[i-1]] = i; pre[i][j + w[i - 1]] = dp[i-1][j]; } if (dp[i][j + w[i-1]] && j + w[i-1] >= l && j + w[i-1] <= u){ int W = j + w[i - 1]; vector<int>ans; while(i != (int)1e9){ ans.push_back(i-1); i = pre[i][W]; W -= w[ans.back()]; } return ans; } } } return std::vector<int>(0); }
#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...