제출 #340573

#제출 시각아이디문제언어결과실행 시간메모리
340573FlashGamezzzRectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <unordered_set> #include <vector> #include <utility> #include "rect.h" using namespace std; int n, m; vector<vector<vector<bool> > > val, val2; vector<vector<vector<int> > > bits; int sum(int rs, int re, int c) { int sum = 0; c++; while (c > 0) { sum += bits[rs][re][c]; c -= c & (-c); } return sum; } void inc(int rs, int re, int c) { c++; while (c <= m) { bits[rs][re][c]++; c += c & (-c); } } long long count_rectangles(vector<vector<int> > a) { n = a.size(); m = a[0].size(); long long ans = 0; val.push_back(vector<vector<bool> >()); val2.push_back(vector<vector<bool> >()); for (int r = 1; r < n-1; r++){ val.push_back(vector<vector<bool> >()); val[r].push_back(vector<bool>()); for (int cs = 1; cs < m-1; cs++){ val[r].push_back(vector<bool>()); int maxv = 0; for (int t = 0; t < cs; t++){ val[r][cs].push_back(false); } for (int ce = cs; ce < m-1; ce++){ maxv = max(maxv, a[r][ce]); if (maxv < a[r][cs-1] && maxv < a[r][ce+1]){ val[r][cs].push_back(true); } else { val[r][cs].push_back(false); } } } } bits.push_back(vector<vector<int> >()); for (int rs = 1; rs < n-1; rs++){ bits.push_back(vector<vector<int> >()); for (int t = 0; t < rs; t++){ bits[rs].push_back(vector<int>()); } for (int re = rs; re < n-1; re++){ bits[rs].push_back(vector<int>()); for (int t = 0; t < m; t++){ bits[rs][re].push_back(0); } } } for (int c = 1; c < m-1; c++){ val2.push_back(vector<vector<int> >()); val2[c].push_back(vector<int>()); for (int rs = 1; rs < n-1; rs++){ val2[c].push_back(vector<bool>()); int maxv = 0; for (int re = rs; re < n-1; re++){ maxv = max(maxv, a[re][c]); if (maxv < a[rs-1][c] && maxv < a[re+1][c]){ inc(rs, re, c); } } } } for (int rs = 1; rs < n-1; rs++){ for (int cs = 1; cs < m-1; cs++){ for (int ce = cs; ce < m-1; ce++){ for (int re = rs; re < n-1; re++){ if (val[re][cs][ce]){ bool valid = true; for (int i = cs; i <= ce; i++){ if (!val2[i][rs][re]){ valid = false; } } if (sum(rs, re, ce) - sum(rs, re, cs-1) >= ce-cs+1){ ans++; } } else { break; } } } } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:66:40: error: no matching function for call to 'std::vector<std::vector<std::vector<bool> > >::push_back(std::vector<std::vector<int> >)'
   66 |   val2.push_back(vector<vector<int> >()); val2[c].push_back(vector<int>());
      |                                        ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from rect.cpp:5:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::vector<bool> >; _Alloc = std::allocator<std::vector<std::vector<bool> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::vector<bool> >]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const value_type&' {aka 'const std::vector<std::vector<bool> >&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::vector<bool> >; _Alloc = std::allocator<std::vector<std::vector<bool> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::vector<bool> >]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::vector<std::vector<std::vector<bool> > >::value_type&&' {aka 'std::vector<std::vector<bool> >&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
rect.cpp:66:74: error: no matching function for call to 'std::vector<std::vector<bool> >::push_back(std::vector<int>)'
   66 |   val2.push_back(vector<vector<int> >()); val2[c].push_back(vector<int>());
      |                                                                          ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from rect.cpp:5:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; std::vector<_Tp, _Alloc>::value_type = std::vector<bool>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const value_type&' {aka 'const std::vector<bool>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; std::vector<_Tp, _Alloc>::value_type = std::vector<bool>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<bool> >::value_type&&' {aka 'std::vector<bool>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~