Submission #1330229

#TimeUsernameProblemLanguageResultExecution timeMemory
1330229opal_Inwza007xQuality Of Living (IOI10_quality)C++20
Compilation error
0 ms0 KiB
typedef long long ll;

ll rectangle(ll n, ll m, ll h, ll w, ll arr[maxn][maxn]) {
    ll l = 1, r = n * m;
    ll rsq[n][m];
    while (l < r) {
        ll mid = l + (r - l) / 2;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                rsq[i][j] = (arr[i][j] <= mid ? 1 : -1) + (i == 0 ? 0 : rsq[i - 1][j]) + (j == 0 ? 0 : rsq[i][j - 1]) - (i == 0 || j == 0 ? 0 : rsq[i - 1][j - 1]);
            }
        }
        bool flg = false;
        for (int i = h - 1; i < n && !flg; i++) {
            for (int j = w - 1; j < m; j++) {
                ll val = rsq[i][j] - (i < h ? 0 : rsq[i - h][j]) - (j < w ? 0 : rsq[i][j - w]) + (i < h || j < w ? 0 : rsq[i - h][j - w]);
                if (val > 0) {
                    flg = true;
                    break;
                }
            }
        }
        if (!flg) {
            l = mid + 1;
        }
        else {
            r = mid;
        }
    }
    cout << l << "\n";
}

Compilation message (stderr)

quality.cpp:3:45: error: 'maxn' was not declared in this scope
    3 | ll rectangle(ll n, ll m, ll h, ll w, ll arr[maxn][maxn]) {
      |                                             ^~~~
quality.cpp:3:51: error: 'maxn' was not declared in this scope
    3 | ll rectangle(ll n, ll m, ll h, ll w, ll arr[maxn][maxn]) {
      |                                                   ^~~~
quality.cpp: In function 'll rectangle(...)':
quality.cpp:4:19: error: 'n' was not declared in this scope
    4 |     ll l = 1, r = n * m;
      |                   ^
quality.cpp:4:23: error: 'm' was not declared in this scope
    4 |     ll l = 1, r = n * m;
      |                       ^
quality.cpp:10:17: error: 'rsq' was not declared in this scope
   10 |                 rsq[i][j] = (arr[i][j] <= mid ? 1 : -1) + (i == 0 ? 0 : rsq[i - 1][j]) + (j == 0 ? 0 : rsq[i][j - 1]) - (i == 0 || j == 0 ? 0 : rsq[i - 1][j - 1]);
      |                 ^~~
quality.cpp:10:30: error: 'arr' was not declared in this scope
   10 |                 rsq[i][j] = (arr[i][j] <= mid ? 1 : -1) + (i == 0 ? 0 : rsq[i - 1][j]) + (j == 0 ? 0 : rsq[i][j - 1]) - (i == 0 || j == 0 ? 0 : rsq[i - 1][j - 1]);
      |                              ^~~
quality.cpp:14:22: error: 'h' was not declared in this scope
   14 |         for (int i = h - 1; i < n && !flg; i++) {
      |                      ^
quality.cpp:15:26: error: 'w' was not declared in this scope
   15 |             for (int j = w - 1; j < m; j++) {
      |                          ^
quality.cpp:16:26: error: 'rsq' was not declared in this scope
   16 |                 ll val = rsq[i][j] - (i < h ? 0 : rsq[i - h][j]) - (j < w ? 0 : rsq[i][j - w]) + (i < h || j < w ? 0 : rsq[i - h][j - w]);
      |                          ^~~
quality.cpp:30:5: error: 'cout' was not declared in this scope
   30 |     cout << l << "\n";
      |     ^~~~
quality.cpp:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^