Submission #840179

#TimeUsernameProblemLanguageResultExecution timeMemory
840179sleepntsheepDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <algorithm> #include <set> #include <deque> std::vector<int> find_subset(int l, int u, std::vector<int> w) { std::sort(w.begin() w.end()); int s = 0, i; std::multiset<int> sub; std::deque<int> lo, hi; for (i = 0; i < (int)w.size(); ++i) if (s + w[i] < l) s += w[i], lo.push_back(w[i]), sub.insert(i); else break; for (int j = i; j < (int)w.size(); ++j) hi.push_back(w[j]); while (s < l && lo.size() && hi.size()) { int d = hi.front() - lo.front(); s += d; sub.erase(sub.find(lo.front())); sub.insert(hi.front()); hi.pop_front(); lo.pop_front(); } if (s < l) return std::vector<int>(); std::vector<int> result(sub.begin(), sub.end()); return result; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:24: error: expected ')' before 'w'
    7 |     std::sort(w.begin() w.end());
      |              ~         ^~
      |                        )
molecules.cpp:7:32: error: no matching function for call to 'sort(std::vector<int>::iterator)'
    7 |     std::sort(w.begin() w.end());
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4849:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4849 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:4849:5: note:   template argument deduction/substitution failed:
molecules.cpp:7:32: note:   candidate expects 2 arguments, 1 provided
    7 |     std::sort(w.begin() w.end());
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:4880:5: note:   template argument deduction/substitution failed:
molecules.cpp:7:32: note:   candidate expects 3 arguments, 1 provided
    7 |     std::sort(w.begin() w.end());
      |                                ^
In file included from /usr/include/c++/10/algorithm:74,
                 from molecules.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:292:1: note:   template argument deduction/substitution failed:
molecules.cpp:7:32: note:   candidate expects 4 arguments, 1 provided
    7 |     std::sort(w.begin() w.end());
      |                                ^
In file included from /usr/include/c++/10/algorithm:74,
                 from molecules.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
molecules.cpp:7:32: note:   candidate expects 3 arguments, 1 provided
    7 |     std::sort(w.begin() w.end());
      |                                ^