Submission #1204553

#TimeUsernameProblemLanguageResultExecution timeMemory
1204553Bui_Quoc_CuongDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h" using namespace std; /* tìm tập i1, i2, ... , im L <= wi1 + wi2 + ... + wim <= R wmax - wmin <= R - L */ bitset <(int)5e5> dp; vector<int> find_subset(int L,int R,vector<int> w) { int n = w.size()-1; dp[0] = 1; for(int i=0;i<=n;i++) { dp|= dp << w[i]; } vector<pair<int,int>> wec; for(int i=0;i<=n;i++) wec.push_back({w[i], i}); sort(wec.begin(),wec.end()); int sum=-1; for(int i=L;i<=R;i++) { if(dp.test(i))sum=i; } vector<int> res; for(int i=n;i>=0;i--) { int val=wec[i].first; int id=wec[i].second; if(sum>=val && dp.test(sum - val)) { sum-= val; res.push_back(id); } } sort(res.begin(),res.end()); return res; }

Compilation message (stderr)

molecules.cpp:9:1: error: 'bitset' does not name a type
    9 | bitset <(int)5e5> dp;
      | ^~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:5: error: 'dp' was not declared in this scope
   13 |     dp[0] = 1;
      |     ^~
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~