Submission #655036

#TimeUsernameProblemLanguageResultExecution timeMemory
655036benjaminkleynDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int max_n = 100000; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); unorderd_map<ll, bitset<max_n>> subsets; subsets[0] = bitset<max_n>(0); for (int i = 0; i < n; i++) { vector<pair<ll, bitset<max_n>>> new_subsets; for (auto [sum, subset] : subsets) { subset[i] = 1; if (sum + w[i] <= u) new_subsets.push_back({sum + w[i], subset}); } for (auto [sum, subset] : new_subsets) { subsets[sum] = subset; if (l <= sum) { vector<int> res; for (int j = 0; j <= i; j++) if (subset[j]) res.push_back(j); return res; } } } return vector<int>(0,0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:5: error: 'unorderd_map' was not declared in this scope
   10 |     unorderd_map<ll, bitset<max_n>> subsets;
      |     ^~~~~~~~~~~~
molecules.cpp:10:20: error: expected primary-expression before ',' token
   10 |     unorderd_map<ll, bitset<max_n>> subsets;
      |                    ^
molecules.cpp:10:34: error: expected primary-expression before '>' token
   10 |     unorderd_map<ll, bitset<max_n>> subsets;
      |                                  ^~
molecules.cpp:10:37: error: 'subsets' was not declared in this scope
   10 |     unorderd_map<ll, bitset<max_n>> subsets;
      |                                     ^~~~~~~
molecules.cpp:19:59: error: no matching function for call to 'std::vector<std::pair<long long int, std::bitset<100000> > >::push_back(<brace-enclosed initializer list>)'
   19 |                 new_subsets.push_back({sum + w[i], subset});
      |                                                           ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, std::bitset<100000> >; _Alloc = std::allocator<std::pair<long long int, std::bitset<100000> > >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, std::bitset<100000> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, std::bitset<100000> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, std::bitset<100000> >; _Alloc = std::allocator<std::pair<long long int, std::bitset<100000> > >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, std::bitset<100000> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, std::bitset<100000> > >::value_type&&' {aka 'std::pair<long long int, std::bitset<100000> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~