Submission #584572

#TimeUsernameProblemLanguageResultExecution timeMemory
5845728e7Rectangles (IOI19_rect)C++17
Compilation error
0 ms0 KiB
#include "rect.h" //Challenge: Accepted #include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 200005 #define mod 1000000007 #define pii pair<int, int> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); long long count_rectangles(std::vector<std::vector<int> > a) { int n = a.size(), m = a[0].size(); vector<vector<bool> > good(m, vector<bool>(m, 0)), row(m, vector<bool>(m, 0)); ll ret = 0; for (int u = 1;u < n - 1;u++) { vector<int> ma(m, 0); vector<pii> p; for (int d = u;d < n - 1;d++) { int lef = 0; stack<int> stk; vector<pii> q; for (int i = 0;i < m;i++) { auto add = [&] (int l, int r) { if (l+1 < r) { if (l >= lef && (u == d || good[l][r])) { ret++; } q.push_back({l, r}); row[l][r] = 1; } }; bool check = 1; while (stk.size() && a[d][i] >= a[d][stk.top()]) { int l = stk.top(); add(l, i); if (a[d][l] == a[d][i]) check = 0; stk.pop(); } if (check && stk.size()) { add(stk.top(), i); } stk.push(i); ma[i] = max(ma[i], a[d][i]); if (ma[i] >= a[u-1][i] || ma[i] >= a[d+1][i]) { lef = i; } } if (u == d) { for (auto x:q) good[x.ff][x.ss] = 1, row[x.ff][x.ss] = 0; p = q; } else { for (auto x:p) good[x.ff][x.ss] &= row[x.ff][x.ss]; p.clear(); for (auto x:q) { if (good[x.ff][x.ss]) p.push_back(x); row[x.ff][x.ss] = 0; } } //for (auto x:p) debug(x.ff, x.ss); //debug(); } for (auto x:p) good[x.ff][x.ss] = 0; } return ret; }

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:69:37: error: no match for 'operator&=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
   69 |     for (auto x:p) good[x.ff][x.ss] &= row[x.ff][x.ss];
      |                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from rect.cpp:3:
/usr/include/c++/10/cstddef:164:3: note: candidate: 'constexpr std::byte& std::operator&=(std::byte&, std::byte)'
  164 |   operator&=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/cstddef:164:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  164 |   operator&=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from rect.cpp:3:
/usr/include/c++/10/bits/ios_base.h:103:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator&=(std::_Ios_Fmtflags&, std::_Ios_Fmtflags)'
  103 |   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:103:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
  103 |   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:145:3: note: candidate: 'const std::_Ios_Openmode& std::operator&=(std::_Ios_Openmode&, std::_Ios_Openmode)'
  145 |   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:145:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  145 |   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:185:3: note: candidate: 'const std::_Ios_Iostate& std::operator&=(std::_Ios_Iostate&, std::_Ios_Iostate)'
  185 |   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:185:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  185 |   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:105,
                 from rect.cpp:3:
/usr/include/c++/10/future:164:18: note: candidate: 'std::launch& std::operator&=(std::launch&, std::launch)'
  164 |   inline launch& operator&=(launch& __x, launch __y)
      |                  ^~~~~~~~
/usr/include/c++/10/future:164:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::launch&'
  164 |   inline launch& operator&=(launch& __x, launch __y)
      |                             ~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:127,
                 from rect.cpp:3:
/usr/include/c++/10/charconv:684:3: note: candidate: 'constexpr std::chars_format& std::operator&=(std::chars_format&, std::chars_format)'
  684 |   operator&=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/charconv:684:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::chars_format&'
  684 |   operator&=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~