QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#519973 | #1819. Cleaning Robot | EdwardH101 | WA | 0ms | 3856kb | C++17 | 1.0kb | 2024-08-15 09:59:57 | 2024-08-15 09:59:58 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int findLargestRobotSize(int n, int m, vector<vector<bool>>& grid) {
vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
int maxSize = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (!grid[i][j]) {
if (i == 1 || j == 1) {
dp[i][j] = 1;
} 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 > 0) ? maxSize : -1;
}
int main() {
int n, m, k;
cin >> n >> m >> k;
vector<vector<bool>> grid(n + 1, vector<bool>(m + 1, false));
for (int i = 0; i < k; ++i) {
int x, y;
cin >> x >> y;
grid[x][y] = true;
}
int result = findLargestRobotSize(n, m, grid);
cout << result << endl;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3856kb
input:
10 7 1 8 3
output:
7
result:
wrong answer expected '2', found '7'