Submission #738139

#TimeUsernameProblemLanguageResultExecution timeMemory
738139MilosMilutinovicRectangles (IOI19_rect)C++14
Compilation error
0 ms0 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; const int N = 2525; int n, m; vector < vector <int> > a, L, R, U, D; vector < vector < pair <int, int> > > ver[N], hor[N]; vector < pair <int, int> > VER[N][N], HOR[N][N]; long long count_rectangles(vector< vector <int> > _a) { n = (int) _a.size(); m = (int) _a[0].size(); a = _a; L = vector < vector <int> >(n, vector <int>(m)); R = vector < vector <int> >(n, vector <int>(m)); U = vector < vector <int> >(n, vector <int>(m)); D = vector < vector <int> >(n, vector <int>(m)); for (int i = 0; i < n; i++) { vector <int> stk; for (int j = 0; j < m; j++) { while (!stk.empty() && a[i][stk.back()] < a[i][j]) stk.pop_back(); L[i][j] = (stk.empty() ? -1 : stk.back()); stk.push_back(j); } } for (int i = 0; i < n; i++) { vector <int> stk; for (int j = m - 1; j >= 0; j--) { while (!stk.empty() && a[i][stk.back()] < a[i][j]) stk.pop_back(); R[i][j] = (stk.empty() ? -1 : stk.back()); stk.push_back(j); } } for (int j = 0; j < m; j++) { vector <int> stk; for (int i = 0; i < n; i++) { while (!stk.empty() && a[stk.back()][j] < a[i][j]) stk.pop_back(); U[i][j] = (stk.empty() ? -1 : stk.back()); stk.push_back(i); } } for (int j = 0; j < m; j++) { vector <int> stk; for (int i = n - 1; i >= 0; i--) { while (!stk.empty() && a[stk.back()][j] < a[i][j]) stk.pop_back(); D[i][j] = (stk.empty() ? -1 : stk.back()); stk.push_back(i); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (L[i][j] != -1 && L[i][j] != j - 1) { hor[i].emplace_back(L[i][j], j); } if (R[i][j] != -1 && R[i][j] != j + 1) { hor[i].emplace_back(j, R[i][j]); } } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (U[i][j] != -1 && U[i][j] != i - 1) { ver[i].emplace_back(U[i][j], i); } if (D[i][j] != -1 && D[i][j] != i + 1) { ver[i].emplace_back(i, D[i][j]); } } } for (int i = 0; i < n; i++) { sort(hor[i].begin(), hor[i].end()); hor[i].erase(unique(hor[i].begin(), hor[i].end()), hor[i].end()); } for (int j = 0; j < m; j++) { sort(ver[j].begin(), ver[j].end()); ver[j].erase(unique(ver[j].begin(), ver[j].end()), ver[j].end()); } }

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:86:1: warning: no return statement in function returning non-void [-Wreturn-type]
   86 | }
      | ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/10/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::vector<std::pair<int, int> >; _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >]':
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::vector<std::pair<int, int> >; _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::vector<std::pair<int, int> > >]'
/usr/include/c++/10/bits/vector.tcc:115:30:   required from 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
rect.cpp:57:47:   required from here
/usr/include/c++/10/ext/new_allocator.h:150:4: error: no matching function for call to 'std::vector<std::pair<int, int> >::vector(int&, int&)'
  150 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/vector:67,
                 from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  653 |  vector(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:653:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/stl_algobase.h:65,
                 from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_types.h: In substitution of 'template<class _InIter> using _RequireInputIter = std::__enable_if_t<std::is_convertible<typename std::iterator_traits< <template-parameter-1-1> >::iterator_category, std::input_iterator_tag>::value> [with _InIter = int]':
/usr/include/c++/10/bits/stl_vector.h:652:9:   required from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::vector<std::pair<int, int> >; _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >]'
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::vector<std::pair<int, int> >; _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::vector<std::pair<int, int> > >]'
/usr/include/c++/10/bits/vector.tcc:115:30:   required from 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
rect.cpp:57:47:   required from here
/usr/include/c++/10/bits/stl_iterator_base_types.h:249:11: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  249 |     using _RequireInputIter =
      |           ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/vector:67,
                 from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/10/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::vector<std::pair<int, int> >; _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >]':
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::vector<std::pair<int, int> >; _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::vector<std::pair<int, int> > >]'
/usr/include/c++/10/bits/vector.tcc:115:30:   required from 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
rect.cpp:57:47:   required from here
/usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]'
  625 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:625:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<int, int> >'
  625 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:607:23: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >&&'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |              ~~~~~~~~~^~~~
/usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >; std::false_type = std::integral_constant<bool, false>]'
  589 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:589:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >; std::true_type = std::integral_constant<bool, true>]'
  585 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:585:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:575:28: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::pair<int, int> >&'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  572 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:572:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  553 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:553:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]'
  522 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:522:47: note:   no known conversion for argument 2 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  522 |       vector(size_type __n, const value_type& __value,
      |                             ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]'
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:510:51: note:   no known conversion for argument 2 from 'int' to 'const allocator_type&' {aka 'const std::allocator<std::pair<int, int> >&'}
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]'
  497 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:497:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  487 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:487:7: note:   candidate expects 0 arguments, 2 provided