Submission #173973

#TimeUsernameProblemLanguageResultExecution timeMemory
173973CaroLindaDetecting Molecules (IOI16_molecules)C++14
31 / 100
125 ms40724 KiB
#include "molecules.h" #include <bits/stdc++.h> #define debug printf #define lp(i,a,b) for(int i = a ; i < b ; i++ ) #define ff first #define ss second #define pb push_back #define mk make_pair #define ll long long #define sz size() #define pii pair<int,int> #define all(x) x.begin(),x.end() #define tiii tuple<int,int,int> #define mkt make_tuple const int MAX = 10010 ; using namespace std ; bool dp[MAX][MAX] ; vector<int> res ; vector<int> find_subset(int l, int u, vector<int> w) { int cnt = 1 ; dp[0][0] = true ; for(int i : w) { dp[cnt][0] = true ; for(int j = u ; j >= 0 ; j-- ) { if( u <= 1000 ) dp[cnt][j] = dp[cnt-1][j] ; if( j + i <= u && u <= 1000 ) dp[cnt][j+i] |= dp[cnt-1][j] ; } cnt ++ ; } cnt -- ; int ok = -1 ; lp(i,l,u+1) if( dp[cnt][i] ) ok = i ; if( ok == -1 ) return res ; for(int i = cnt ; i > 0 ; i-- ) if( w[i-1] <= ok && dp[i][ok] && dp[i-1][ok-w[i-1]] ) { res.pb(i-1) ; ok -= w[i-1] ; } sort(all(res)); 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...