Submission #1102145

# Submission time Handle Problem Language Result Execution time Memory
1102145 2024-10-17T14:40:28 Z akzytr Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	vector<int> result;

	int n = w.size();
	int dp[n + 1][u + 1];

	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= u; j++) {
			dp[i][j] = -1;
		}
	}

	dp[0][0] = 0;
	for(int i = 1; i <= n; i++) {
		for(int s = 0; s <= u; s++) {
			if(s < w[i - 1]) {
				dp[i][s] = dp[i - 1][s];
			}

			else if(dp[i - 1][s - w[i - 1]] != -1) {
				dp[i][s] = i;
			} else {
				dp[i][s] = dp[i - 1][s];
			}
		}
	}

	for(int i = l; i <= u; i++) {
		if(dp[n][i]) {
			int idx = dp[n][i];
			int s = i;
			while(idx != 0) {
				result.pb(idx - 1);
				s -= w[idx - 1];
				idx = dp[idx][s];
			}
			break;
		}
	}

	return result;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:38:12: error: 'class std::vector<int>' has no member named 'pb'
   38 |     result.pb(idx - 1);
      |            ^~