Submission #778568

#TimeUsernameProblemLanguageResultExecution timeMemory
778568khshgThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include"prize.h" #include<bits/stdc++.h> using namespace std; vector<int> memo; vector<int> K(int i) { if(memo[i][0] != -1) return memo[i]; return ask(i); } int find_best(int N) { memo.resize(N, {-1, -1}); int i = 0; int mx = 0; for(; i < 473; ++i) { vector<int> e = K(i); int sum = e[0] + e[1]; if(!sum) return i; mx = max(mx, e[0] + e[1]); } while(true) { vector<int> e = K(i); int sum = e[0] + e[1]; if(!sum) return i; if(sum != mx) { ++i; continue; } int tl = i + 1, tr = N; while(tl < tr) { int tm = (tl + tr) / 2; vector<int> E = ask(tm); if(e == E) { tl = tm + 1; } else { tr = tm; } } i = tr; } }

Compilation message (stderr)

prize.cpp: In function 'std::vector<int> K(int)':
prize.cpp:7:12: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    7 |  if(memo[i][0] != -1) return memo[i];
      |            ^
prize.cpp:7:36: error: could not convert 'memo.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
    7 |  if(memo[i][0] != -1) return memo[i];
      |                                    ^
      |                                    |
      |                                    __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
prize.cpp: In function 'int find_best(int)':
prize.cpp:12:25: error: no matching function for call to 'std::vector<int>::resize(int&, <brace-enclosed initializer list>)'
   12 |  memo.resize(N, {-1, -1});
      |                         ^
In file included from /usr/include/c++/10/vector:67,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:54: note:   no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |                                    ~~~~~~~~~~~~~~~~~~^~~