Submission #957587

#TimeUsernameProblemLanguageResultExecution timeMemory
957587vjudge1Robots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #include "robots.h" int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { vector <pair<int,int>> vec; for(ll i=0;i<a;i++){ vec.pb({x[i],1}); } for(ll i=0;i<t;i++){ vec.pb({w[i],s[i]}); } sort(vec.begin(),vec.end()); sort(y,y+b,greater<int>()); int l=0; int r=t+1; int ans=-1; while(l<r){ int md=(l+r)>>1; bool ok=1; priority_queue<pii>pq; for(int i=0;i<(int)vec.size();i++){ if(vec[i].se==1){ for(int j=0;j<md;j++){ if(pq.size())pq.pop(); } } else{ pq.push(vec[i]); } } priority_queue<ll> pq2; while(pq.size()){ pq2.push(pq.top().se); pq.pop(); } for(int i=0;i<b;i++){ if(!pq2.size())break; if(pq2.top()>=y[i]){ ok=0; break; } else{ for(int j=0;j<md;j++){ if(pq2.size())pq2.pop(); } } } if(ok){ ans=md; r=md; } else{ l=md+1; } } return ans; } /* ---------------------------------------------------go get gold--------------------------------------------------------------------- - If u see the problem dp there's many option to iterate, u can iterate from 1- n or 1 - (possible max number) - If u see the problem that has unexpected constraint u can divide it into 2 problem - If u see the problem that can use binary search, then u can use binser + check condition - in interactive problem there's many trick using binser - kalo misal mau cari yang sama pake pernah ke visit ga bilangan itu - kalo problem yang high itu biasanya optimisasi nya pake 2 array - dp bisa aja kek kamu tenzing balls dimana optimisasi 2 dp - janlup fibonacci - kalo binser mending r = 3 * 1e18 aja - kalo mau dibalik itu pake value nya tinggal diubah ke size */

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:8:9: error: 'll' was not declared in this scope
    8 |     for(ll i=0;i<a;i++){
      |         ^~
robots.cpp:8:16: error: 'i' was not declared in this scope
    8 |     for(ll i=0;i<a;i++){
      |                ^
robots.cpp:9:24: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
    9 |         vec.pb({x[i],1});
      |                        ^
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 robots.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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 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<int, int>&'}
 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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 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<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
robots.cpp:11:9: error: 'll' was not declared in this scope
   11 |     for(ll i=0;i<t;i++){
      |         ^~
robots.cpp:11:16: error: 'i' was not declared in this scope
   11 |     for(ll i=0;i<t;i++){
      |                ^
robots.cpp:12:27: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   12 |         vec.pb({w[i],s[i]});
      |                           ^
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 robots.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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 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<int, int>&'}
 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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 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<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
robots.cpp:22:24: error: 'pii' was not declared in this scope
   22 |         priority_queue<pii>pq;
      |                        ^~~
robots.cpp:22:27: error: template argument 1 is invalid
   22 |         priority_queue<pii>pq;
      |                           ^
robots.cpp:22:27: error: template argument 2 is invalid
robots.cpp:22:27: error: template argument 3 is invalid
robots.cpp:24:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se'
   24 |             if(vec[i].se==1){
      |                       ^~
robots.cpp:26:27: error: request for member 'size' in 'pq', which is of non-class type 'int'
   26 |                     if(pq.size())pq.pop();
      |                           ^~~~
robots.cpp:26:37: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   26 |                     if(pq.size())pq.pop();
      |                                     ^~~
robots.cpp:30:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   30 |                 pq.push(vec[i]);
      |                    ^~~~
robots.cpp:33:24: error: 'll' was not declared in this scope; did you mean 'l'?
   33 |         priority_queue<ll> pq2;
      |                        ^~
      |                        l
robots.cpp:33:26: error: template argument 1 is invalid
   33 |         priority_queue<ll> pq2;
      |                          ^
robots.cpp:33:26: error: template argument 2 is invalid
robots.cpp:33:26: error: template argument 3 is invalid
robots.cpp:34:18: error: request for member 'size' in 'pq', which is of non-class type 'int'
   34 |         while(pq.size()){
      |                  ^~~~
robots.cpp:35:17: error: request for member 'push' in 'pq2', which is of non-class type 'int'
   35 |             pq2.push(pq.top().se);
      |                 ^~~~
robots.cpp:35:25: error: request for member 'top' in 'pq', which is of non-class type 'int'
   35 |             pq2.push(pq.top().se);
      |                         ^~~
robots.cpp:36:16: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   36 |             pq.pop();
      |                ^~~
robots.cpp:39:21: error: request for member 'size' in 'pq2', which is of non-class type 'int'
   39 |             if(!pq2.size())break;
      |                     ^~~~
robots.cpp:40:20: error: request for member 'top' in 'pq2', which is of non-class type 'int'
   40 |             if(pq2.top()>=y[i]){
      |                    ^~~
robots.cpp:46:28: error: request for member 'size' in 'pq2', which is of non-class type 'int'
   46 |                     if(pq2.size())pq2.pop();
      |                            ^~~~
robots.cpp:46:39: error: request for member 'pop' in 'pq2', which is of non-class type 'int'
   46 |                     if(pq2.size())pq2.pop();
      |                                       ^~~