제출 #1267078

#제출 시각아이디문제언어결과실행 시간메모리
1267078herominhsteve삶의 질 (IOI10_quality)C++20
컴파일 에러
0 ms0 KiB
#include "quality.h" #include <bits/stdc++.h> const int MAXN = 3005; int rectangle(int n,int m,int H,int W, int grid[MAXN][MAXN]){ int l=1, r = n * m; int res = r; vector<vector<int>> pre(n,vector<int>(m,0)); function<bool(int)> check = [&] (int mid) -> bool { for (int i=0;i<n;i++){ for (int j=0;j<m;j++){ int cur = (grid[i][j] <= mid ? 1 : -1); int upperHalf = (!i ? 0 : pre[i-1][j]); int leftHalf = (!j ? 0 : pre[i][j-1]); int overlap = ((i and j) ? pre[i-1][j-1] : 0); pre[i][j] = upperHalf + leftHalf - overlap + cur; } } for (int i = H-1; i < n; i++) { for (int j = W-1; j < m; j++) { int cur = pre[i][j] - (i-H >= 0 ? pre[i-H][j] : 0) - (j-W >= 0 ? pre[i][j-W] : 0) + (i-H >= 0 and j-W >= 0 ? pre[i-H][j-W] : 0); if (cur > 0) return true; } } return false; }; while (l<=r){ int mid = (l+r)>>1; if (check(mid)){ res = mid; r=mid-1; } else{ l = mid + 1; } } return res; }

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

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3005])':
quality.cpp:9:16: error: 'vector' was not declared in this scope
    9 |         vector<vector<int>> pre(n,vector<int>(m,0));
      |                ^~~~~~
quality.cpp:9:16: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from quality.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from quality.cpp:2:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
quality.cpp:9:23: error: expected primary-expression before 'int'
    9 |         vector<vector<int>> pre(n,vector<int>(m,0));
      |                       ^~~
quality.cpp:11:9: error: 'function' was not declared in this scope; did you mean 'std::function'?
   11 |         function<bool(int)>  check = [&] (int mid) -> bool {
      |         ^~~~~~~~
      |         std::function
In file included from /usr/include/c++/11/functional:59,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from quality.cpp:2:
/usr/include/c++/11/bits/std_function.h:111:11: note: 'std::function' declared here
  111 |     class function;
      |           ^~~~~~~~
quality.cpp:11:18: error: expected primary-expression before 'bool'
   11 |         function<bool(int)>  check = [&] (int mid) -> bool {
      |                  ^~~~
quality.cpp:35:21: error: 'check' was not declared in this scope
   35 |                 if (check(mid)){
      |                     ^~~~~