QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488503#1819. Cleaning RobotEdwardH101WA 0ms3580kbC++171.3kb2024-07-24 08:48:532024-07-24 08:48:55

Judging History

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

  • [2024-07-24 08:48:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-07-24 08:48:53]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int maxRobotSize(int n, int m, int k, vector<pair<int, int>>& obstructions) {
    vector<vector<int>> room(n, vector<int>(m, 0));
    
    for (auto& obstruction : obstructions) {
        room[obstruction.first - 1][obstruction.second - 1] = 1;
    }
    
    vector<vector<int>> dp(n, vector<int>(m, 0));
    int maxSize = 0;
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (room[i][j] == 1) {
                dp[i][j] = 0;
            } else {
                if (i == 0 || j == 0) {
                    dp[i][j] = 1;  // On the border, a non-obstructed cell can form a 1x1 square
                } else {
                    dp[i][j] = min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}) + 1;
                }
                maxSize = max(maxSize, dp[i][j]);
            }
        }
    }
    
    return maxSize;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, k;
    cin >> n >> m >> k;

    vector<pair<int, int>> obstructions(k);
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y;
        obstructions[i] = {x, y};
    }

    int result = maxRobotSize(n, m, k, obstructions);
    cout << result << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

input:

10 7 1
8 3

output:

7

result:

wrong answer expected '2', found '7'