제출 #574071

#제출 시각아이디문제언어결과실행 시간메모리
574071EliasDetecting Molecules (IOI16_molecules)C++17
10 / 100
1 ms300 KiB
#include <bits/stdc++.h> #ifndef _DEBUG #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include "molecules.h" #endif using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> a; for (int x : w) { if (x > u) continue; if (x >= l) return {x}; a.push_back(x); } int n = a.size(); vector<vector<bool>> dp(n + 1, vector<bool>(u + 1)); for (int i = 0; i <= n; i++) dp[i][0] = 1; int i, j; for (i = 1; i <= n; i++) for (j = 1; j <= u; j++) { dp[i][j] = dp[i - 1][j]; if (a[i - 1] <= j) dp[i][j] = dp[i][j] | dp[i - 1][j - a[i - 1]]; if (j >= l && j <= u && dp[i][j]) goto out; } return {}; out: vector<int> o; while (i) { if (!dp[i - 1][j]) { o.push_back(i - 1); j -= a[i - 1]; } i--; } return o; } #ifdef _DEBUG signed main() { int n, l, u; cin >> n >> l >> u; vector<int> a(n); for (int &x : a) cin >> x; for (int x : find_subset(l, u, a)) cout << x << " "; } #endif
#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...