Submission #1102184

# Submission time Handle Problem Language Result Execution time Memory
1102184 2024-10-17T15:47:29 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();
	bitset<30002> dp[n + 1];

	dp[0][0] = 1;

	for(int i = 0; i < n; i++) {
		dp[i + 1] |= (dp[i] << w[i]);
	}

	for(int i = l; i <= u; i++) {
		if(dp[i]) {
			int cur_s = i;
			for(int j = n - 1; j >= 0; j--) {
				if(cur_s - w[j] >= 0 && dp[j][cur_s - w[j]]) {
					cur_s -= w[j];
					result.push_back(j);
				}
				if(cur_s == 0) {
					break;
				}
			}
			break;
		}
	}

	return result;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:10: error: could not convert 'dp[i]' from 'std::bitset<30002>' to 'bool'
   19 |   if(dp[i]) {
      |      ~~~~^
      |          |
      |          std::bitset<30002>