Submission #1267080

#TimeUsernameProblemLanguageResultExecution timeMemory
1267080herominhsteveQuality Of Living (IOI10_quality)C++20
Compilation error
0 ms0 KiB
#include "quality.h" #include <bits/stdc++.h> using namespace std; int rectangle(int n,int m,int H,int W, int grid[][]){ 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; }

Compilation message (stderr)

quality.cpp:5:44: error: declaration of 'grid' as multidimensional array must have bounds for all dimensions except the first
    5 | int rectangle(int n,int m,int H,int W, int grid[][]){
      |                                            ^~~~
quality.cpp: In function 'int rectangle(...)':
quality.cpp:6:22: error: 'n' was not declared in this scope
    6 |         int l=1, r = n * m;
      |                      ^
quality.cpp:6:26: error: 'm' was not declared in this scope
    6 |         int l=1, r = n * m;
      |                          ^
quality.cpp: In lambda function:
quality.cpp:13:44: error: 'grid' was not declared in this scope
   13 |                                 int cur = (grid[i][j] <= mid ? 1 : -1);
      |                                            ^~~~
quality.cpp:20:30: error: 'H' was not declared in this scope
   20 |                 for (int i = H-1; i < n; i++) {
      |                              ^
quality.cpp:21:38: error: 'W' was not declared in this scope
   21 |                         for (int j = W-1; j < m; j++) {
      |                                      ^