Submission #390575

#TimeUsernameProblemLanguageResultExecution timeMemory
390575faresbasbsThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; vector<vector<int>> p[200001]; vector<int> askk(int pos){ if(p[pos].size()){ return p[pos]; } return p[pos] = ask(pos); } int find_best(int n){ int sum = 0; for(int i = 0 ; i < 450 ; i += 1){ int a = rand()%n; vector<int> v = askk(a); sum = max(sum,v[0]+v[1]); if(v[0]+v[1] == 0){ return a; } } vector<pair<int,vector<int>>> v; int p = 0; while(p < n){ while(p < n){ vector<int> f = askk(p); if(f[0]+f[1] == sum){ v.push_back({p,f}); break; }else{ if(f[0]+f[1] == 0){ return p; } p += 1; } } p += 450; } v.push_back({n,{sum,0}}); for(int i = 0 ; i+1 < v.size() ; i += 1){ while(v[i+1].second[0] != v[i].second[0]){ int first = v[i].first , last = v[i+1].first; while(last-first > 1){ int mid = (first+last)/2; vector<int> f = askk(mid); if(f[0]+f[1] == 0){ return mid; } if(f[0]+f[1] == sum && f[0] == v[i].second[0]){ first = mid; }else{ last = mid; } } vector<int> f; for(int j = first+2 ; j < n ; j += 1){ f = askk(j); if(f[0]+f[1] == 0){ return j; } if(f[0]+f[1] == sum){ v[i] = {j,f}; break; } } } } } /*int main(){ cout << find_best(8) << endl; }*/

Compilation message (stderr)

prize.cpp: In function 'std::vector<int> askk(int)':
prize.cpp:8:21: error: could not convert 'p[pos]' from 'vector<std::vector<int>>' to 'vector<int>'
    8 |         return p[pos];
      |                ~~~~~^
      |                     |
      |                     vector<std::vector<int>>
prize.cpp:10:28: error: no match for 'operator=' (operand types are 'std::vector<std::vector<int> >' and 'std::vector<int>')
   10 |     return p[pos] = ask(pos);
      |                            ^
In file included from /usr/include/c++/9/vector:72,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from prize.cpp:1:
/usr/include/c++/9/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<std::vector<int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from prize.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:706:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:706:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<int> >&&'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:727:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  727 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:727:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<std::vector<int> >'
  727 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:41:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0 ; i+1 < v.size() ; i += 1){
      |                     ~~~~^~~~~~~~~~
prize.cpp:23:35: warning: control reaches end of non-void function [-Wreturn-type]
   23 |     vector<pair<int,vector<int>>> v;
      |                                   ^