Submission #266708

#TimeUsernameProblemLanguageResultExecution timeMemory
266708dennisstarRectangles (IOI19_rect)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "rect.h" #define fi first #define se second #define em emplace #define eb emplace_back using namespace std; using ll = long long; int N, M, A; vector<tuple<int, int, int>> H, V; ll count_rectangles(vector<vector<int>> a) { N=a.size(); M=a[0].size(); vector<vector<int>> l, r, u, d; for (int i=0; i<N; i++) l.eb(vector<int>(M, -1)); r=u=d=l; for (int i=0; i<N; i++) { vector<int> st; for (int j=0; j<M; j++) { while (st.size()&&a[i][st.back()]<a[i][j]) st.pop_back(); if (st.size()) H.eb(st.back(), j, i); st.eb(j); } st.clear(); for (int j=M-1; j>=0; j--) { while (st.size()&&a[i][st.back()]<a[i][j]) st.pop_back(); if (st.size()) H.eb(j, st.back(), i); st.eb(j); } st.clear(); for (int j=0; j<M; j++) { while (st.size()&&a[i][st.back()]<=a[i][j]) st.pop_back(); if (st.size()) l[i][j]=st.back(); st.eb(j); } st.clear(); for (int j=M-1; j>=0; j--) { while (st.size()&&a[i][st.back()]<=a[i][j]) st.pop_back(); if (st.size()) r[i][j]=st.back(); st.eb(j); } } for (int j=0; j<M; j++) { vector<int> st; for (int i=0; i<N; i++) { while (st.size()&&a[st.back()][j]<a[i][j]) st.pop_back(); if (st.size()) V.eb(st.back(), i, j); st.eb(i); } st.clear(); for (int i=N-1; i>=0; i--) { while (st.size()&&a[st.back()][j]<a[i][j]) st.pop_back(); if (st.size()) V.eb(i, st.back(), j); st.eb(i); } st.clear(); for (int i=0; i<N; i++) { while (st.size()&&a[st.back()][j]<=a[i][j]) st.pop_back(); if (st.size()) u[i][j]=st.back(); st.eb(i); } st.clear(); for (int i=N-1; i>=0; i--) { while (st.size()&&a[st.back()][j]<=a[i][j]) st.pop_back(); if (st.size()) d[i][j]=st.back(); st.eb(i); } } sort(H.begin(), H.end()); H.resize(unique(H.begin(), H.end())-H.begin()); sort(V.begin(), V.end()); V.resize(unique(V.begin(), V.end())-V.begin()); for (int i=1; i<N-1; i++) for (int j=1; j<M-1; j++) { int L=l[i][j], R=r[i][j], U=u[i][j], D=d[i][j]; if (L==-1||R==-1||U==-1||D==-1) continue; int b1=lower_bound(H.begin(), H.end(), tie(L, R, U+1))-H.begin(); int b2=lower_bound(H.begin(), H.end(), tie(L, R, D-1))-H.begin(); if (b1>=H.size()||tie(L, R, U+1)<H[b1]) continue; if (b2>=H.size()||tie(L, R, D-1)<H[b2]) continue; if (b2-b1!=D-U-2) continue; b1=lower_bound(V.begin(), V.end(), tie(U, D, L+1))-V.begin(); b2=lower_bound(V.begin(), V.end(), tie(U, D, R-1))-V.begin(); if (b1>=V.size()||tie(U, D, L+1)<V[b1]) continue; if (b2>=V.size()||tie(U, D, R-1)<V[b2]) continue; if (b2-b1!=R-L-2) continue; A++; } return A; }

Compilation message (stderr)

rect.cpp: In function 'll count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:84:53: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   84 |   int b1=lower_bound(H.begin(), H.end(), tie(L, R, U+1))-H.begin();
      |                                                    ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:85:53: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   85 |   int b2=lower_bound(H.begin(), H.end(), tie(L, R, D-1))-H.begin();
      |                                                    ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:86:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |   if (b1>=H.size()||tie(L, R, U+1)<H[b1]) continue;
      |       ~~^~~~~~~~~~
rect.cpp:86:32: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   86 |   if (b1>=H.size()||tie(L, R, U+1)<H[b1]) continue;
      |                               ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:87:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |   if (b2>=H.size()||tie(L, R, D-1)<H[b2]) continue;
      |       ~~^~~~~~~~~~
rect.cpp:87:32: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   87 |   if (b2>=H.size()||tie(L, R, D-1)<H[b2]) continue;
      |                               ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:90:49: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   90 |   b1=lower_bound(V.begin(), V.end(), tie(U, D, L+1))-V.begin();
      |                                                ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:91:49: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   91 |   b2=lower_bound(V.begin(), V.end(), tie(U, D, R-1))-V.begin();
      |                                                ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:92:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |   if (b1>=V.size()||tie(U, D, L+1)<V[b1]) continue;
      |       ~~^~~~~~~~~~
rect.cpp:92:32: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   92 |   if (b1>=V.size()||tie(U, D, L+1)<V[b1]) continue;
      |                               ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
rect.cpp:93:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |   if (b2>=V.size()||tie(U, D, R-1)<V[b2]) continue;
      |       ~~^~~~~~~~~~
rect.cpp:93:32: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   93 |   if (b2>=V.size()||tie(U, D, R-1)<V[b2]) continue;
      |                               ~^~
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/9/tuple:1611:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1611 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~