Submission #972409

#TimeUsernameProblemLanguageResultExecution timeMemory
972409TanosDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define x first #define y second #define all(x) x.begin(), x.end() #define el "\n" #define pb push_back #define pp pop_back #define pii pair <int, int> #define pll pair <ll, ll> #define ibase ios_base::sync_with_stdio(0), cin.tie(0); const int N = 5e5 + 5, M = 1e3 + 5, pw = 31; const ll MAX = 1e15, inf = 1e9 + 7; vector <int> find_subset(ll l, ll u, vector <int> a) { int n = a.size(); vector<pair <int, int>> p; for (int i = 0; i < n; i++) { p.pb({a[i], i}); } sort(p.begin(), p.end()); reverse() ll sum = 0, j = 0, last = 0; for (int i = 0; i < n; i++) { sum += p[i].x; last = i; if (sum >= l && sum <= u) { break; } else if (sum >= l) { j = 0; while (sum > u) sum -= p[j++].x; if (sum >= l) break; } } if (l > sum || sum > u) return {}; vector <int> ans; for (int i = j; i <= last; i++) ans.pb(p[i].y); return ans; } //void solve() { //

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(long long int, long long int, std::vector<int>)':
molecules.cpp:26:10: error: no matching function for call to 'reverse()'
   26 |  reverse()
      |          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:1165:5: note: candidate: 'template<class _BIter> void std::reverse(_BIter, _BIter)'
 1165 |     reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:1165:5: note:   template argument deduction/substitution failed:
molecules.cpp:26:10: note:   candidate expects 2 arguments, 0 provided
   26 |  reverse()
      |          ^
In file included 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/pstl/glue_algorithm_defs.h:249:1: note: candidate: 'template<class _ExecutionPolicy, class _BidirectionalIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator)'
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:249:1: note:   template argument deduction/substitution failed:
molecules.cpp:26:10: note:   candidate expects 3 arguments, 0 provided
   26 |  reverse()
      |          ^
molecules.cpp:29:3: error: 'sum' was not declared in this scope
   29 |   sum += p[i].x;
      |   ^~~
molecules.cpp:30:3: error: 'last' was not declared in this scope
   30 |   last = i;
      |   ^~~~
molecules.cpp:35:4: error: 'j' was not declared in this scope
   35 |    j = 0;
      |    ^
molecules.cpp:42:10: error: 'sum' was not declared in this scope
   42 |  if (l > sum || sum > u)
      |          ^~~
molecules.cpp:45:15: error: 'j' was not declared in this scope
   45 |  for (int i = j; i <= last; i++)
      |               ^
molecules.cpp:45:23: error: 'last' was not declared in this scope
   45 |  for (int i = j; i <= last; i++)
      |                       ^~~~