Submission #550862

#TimeUsernameProblemLanguageResultExecution timeMemory
550862David_MRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define pb push_back int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { int ans=-1; vector<array<int, 3>> p(T); set<array<int, 2>> v; for (int i=0; i<T; i++)p[i]={W[i], S[i], i},v.insert({S[i],i}); sort(all(p));sort(X, X+A);sort(Y, Y+B); int l=1, r=T+1; while(l<=r){ int m=l+r>>1; int M=0, k=0; vector<bool> f(T,0); vector<int> v; priority_queue<array<int, 2>> s; for (int e=0; e<A; e++){int x=X[e];M=m; while(k<T && x>p[k][0]) s.push({p[k][1],p[k][2]}), k++; while(!s.empty() && M--) v.erase(s.top()), s.pop(); } for (int e=0; e<B; e++){int y=Y[e];M=m; while(s.size() && M-- && y>(*s.begin())[0]) s.erase(s.begin()); } if(s.size())l=m+1; else ans=m, r=m-1; } return ans; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:16:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   16 |         int m=l+r>>1;
      |               ~^~
robots.cpp:23:53: error: no matching function for call to 'std::vector<int>::erase(const value_type&)'
   23 |             while(!s.empty() && M--) v.erase(s.top()), s.pop();
      |                                                     ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from 'const value_type' {aka 'const std::array<int, 2>'} to 'std::vector<int>::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
robots.cpp:26:44: error: 'class std::priority_queue<std::array<int, 2> >' has no member named 'begin'
   26 |             while(s.size() && M-- && y>(*s.begin())[0])
      |                                            ^~~~~
robots.cpp:27:19: error: 'class std::priority_queue<std::array<int, 2> >' has no member named 'erase'
   27 |                 s.erase(s.begin());
      |                   ^~~~~
robots.cpp:27:27: error: 'class std::priority_queue<std::array<int, 2> >' has no member named 'begin'
   27 |                 s.erase(s.begin());
      |                           ^~~~~