Submission #1102184

#TimeUsernameProblemLanguageResultExecution timeMemory
1102184akzytrDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
// #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 (stderr)

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>