Submission #1174977

#TimeUsernameProblemLanguageResultExecution timeMemory
1174977vahagngQuality Of Living (IOI10_quality)C++20
Compilation error
0 ms0 KiB
#include "quality.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(v) v.begin(),v.end()

ll pref[110][110];

ll check(ll x){
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            pref[i][j] = 0;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + (a[i][j] <= x ? 1 : -1);
        }
    }
    auto qry = [&](int x1, int y1, int x2, int y2){
        return pref[x2][y2] - pref[x1-1][y2] - pref[x2][y1-1] + pref[x1-1][y1-1];
    };
    ll mx = -h*w;
    for(int x1 = 1, x2 = h; x2 <= n; x1++, x2++){
        for(int y1 = 1, y2 = w; y2 <= m; y1++, y2++){
            mx = max(mx, qry(x1,y1,x2,y2));
        }
    }
    return mx;
}

int rectangle(int n, int m, int h, int w, int a[3001][3001]) {
    for(int i = 1; i <= n*m; i++){
		if(check(i) > 0) return i;
	}
}

Compilation message (stderr)

quality.cpp: In function 'long long int check(long long int)':
quality.cpp:11:25: error: 'n' was not declared in this scope
   11 |     for(int i = 0; i <= n; i++){
      |                         ^
quality.cpp:12:29: error: 'm' was not declared in this scope
   12 |         for(int j = 0; j <= m; j++){
      |                             ^
quality.cpp:16:25: error: 'n' was not declared in this scope
   16 |     for(int i = 1; i <= n; i++){
      |                         ^
quality.cpp:17:29: error: 'm' was not declared in this scope
   17 |         for(int j = 1; j <= m; j++){
      |                             ^
quality.cpp:18:74: error: 'a' was not declared in this scope
   18 |             pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + (a[i][j] <= x ? 1 : -1);
      |                                                                          ^
quality.cpp:24:14: error: 'h' was not declared in this scope
   24 |     ll mx = -h*w;
      |              ^
quality.cpp:24:16: error: 'w' was not declared in this scope
   24 |     ll mx = -h*w;
      |                ^
quality.cpp:25:35: error: 'n' was not declared in this scope
   25 |     for(int x1 = 1, x2 = h; x2 <= n; x1++, x2++){
      |                                   ^
quality.cpp:26:39: error: 'm' was not declared in this scope; did you mean 'mx'?
   26 |         for(int y1 = 1, y2 = w; y2 <= m; y1++, y2++){
      |                                       ^
      |                                       mx
quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^