제출 #1101069

#제출 시각아이디문제언어결과실행 시간메모리
1101069SulA삶의 질 (IOI10_quality)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define bitcount __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;

int rectangle(int n, int m, int h, int w, int a[3000][3000]) {
    auto check = [&](int x) {
        vector<vector<int>> g(n, vector<int>(m, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                g[i][j] = a[i][j] <= x ? 1 : -1;
                if (i != 0) g[i][j] += g[i-1][j];
                if (j != 0) g[i][j] += g[i][j-1];
                if (i != 0 && j != 0) g[i][j] -= g[i-1][j-1];
            }
        }
        auto sum = [&](int x1, int y1, int x2, int y2) {
            int sum = g[x2][y2];
            if (x1 != 0) sum -= g[x1 - 1][y2];
            if (y1 != 0) sum -= g[x2][y1 - 1];
            if (x1 != 0 && y1 != 0) sum += g[x1 - 1][y1 - 1];
            return sum;
        };
        int mx = -h*w;
        for (int x1 = 0, x2 = h-1; x2 < n; x1++, x2++) {
            for (int y1 = 0, y2 = w-1; y2 < m; y1++, y2++) {
                int s = sum(x1, y1, x2, y2);
                mx = max(mx, s);
            }
        }
        return mx;
    };

    int ans = 0;
    int l = 1, r = n*m;
    for (int i = l; i <= r; i++) if (check(i) > 0) return i;
    assert(false);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n,m,h,w; cin >> n >> m >> h >> w;
    vector<vector<int>> a(n, vector<int>(m));
    for (auto& r : a) for (auto& x : r) cin >> x;
    cout << rectangle(n,m,h,w,a);
}

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

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3000])':
quality.cpp:37:9: warning: unused variable 'ans' [-Wunused-variable]
   37 |     int ans = 0;
      |         ^~~
quality.cpp: In function 'int main()':
quality.cpp:50:31: error: cannot convert 'std::vector<std::vector<int> >' to 'int (*)[3000]'
   50 |     cout << rectangle(n,m,h,w,a);
      |                               ^
      |                               |
      |                               std::vector<std::vector<int> >
quality.cpp:9:47: note:   initializing argument 5 of 'int rectangle(int, int, int, int, int (*)[3000])'
    9 | int rectangle(int n, int m, int h, int w, int a[3000][3000]) {
      |                                           ~~~~^~~~~~~~~~~~~