제출 #366723

#제출 시각아이디문제언어결과실행 시간메모리
366723BartolMDetecting Molecules (IOI16_molecules)C++17
46 / 100
15 ms12808 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;

const int INF=0x3f3f3f3f;
const int N=10003;

int n;
bitset <N> dp[N];
vector <int> sol;

vector<int> find_subset(int l, int u, vector<int> w) {
    dp[0][0]=1;
    n=w.size();
    for (int i=1; i<=n; ++i) {
        int x=w[i-1];
        dp[i]=dp[i-1]<<x;
        dp[i]|=dp[i-1];
    }
    int res=-1;
    for (int i=l; i<=u; ++i) {
        if (dp[n][i]) {
            res=i;
            break;
        }
    }
    if (res==-1) return sol;
    pii pp=mp(n, res);
    while (pp.Y) {
        int x=w[pp.X-1];
        if (dp[pp.X-1][pp.Y]) pp.X--;
        else pp.X--, pp.Y-=x, sol.pb(pp.X);
    }
    return sol;
}

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