QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#486772#1819. Cleaning RobotXC230595Compile Error//C++171.4kb2024-07-22 01:11:252024-07-22 01:11:25

Judging History

你现在查看的是最新测评结果

  • [2024-07-22 01:11:25]
  • 评测
  • [2024-07-22 01:11:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

bool works(int n, int m, vector<vector<int>> &carpet, int s) {
    vector<vector<int>> ps(n+1, vector<int>(m+1)), clean(n+2, vector<int>(m+2));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            ps[i][j] = ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1] + carpet[i][j];
        }
    }

    for (int i = 1; i <= n-s+1; i++) {
        for (int j = 1; j <= m-s+1; j++) {
            if (ps[i+s-1][j+s-1]-ps[i+s-1][j-1]-ps[i-1][j+s-1]+ps[i-1][j-1] == 0) {
                clean[i][j]++; clean[i+s][j]--; clean[i][j+s]--; clean[i+s][j+s]++;
            }
        }
    }

    vector<vector<int>> cps(n+1, vector<int>(m+1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cps[i][j] = cps[i-1][j] + cps[i][j-1] - cps[i-1][j-1] + clean[i][j];
            if (!carpet[i][j] && cps[i][j] == 0) return false;
        }
    }
    return true;
}

int main() {
    // input
    int n, m, k; cin >> n >> m >> k;
    vector<vector<int>> carpet(n+1, vector<int>(m+1));
    for (int i = 0; i < k; i++) {
        int x, y; cin >> x >> y;
        carpet[x][y] = true;
    }

    // binary search
    int l = 1, r = min(n, m);
    while (l < r) {
        int s = (l+r+1)/2;
        if (works(n, m, carpet, s)) {
            l = s;
        } else {
            r = s-1;
        }
    }
    cout << l << endl;
}

Details

cc1plus: error: ‘::main’ must return ‘int’