이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2525;
int m, n, maxRow[N][N], maxCol[N][N], sum[N][N];
vector<vector<int>> a;
long long subtask5()
{
return 0;
}
int getSum(int x, int y, int xx, int yy)
{
return sum[xx][yy] + sum[x][y] - sum[xx][y] - sum[x][yy];
}
long long subtask6()
{
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++)
sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i - 1][j - 1];
vector<int> maxCol(n + 1, 0);
long long ans = 0;
for (int i = 2; i < m; i++)
{
int maxRow = 0;
for (int j = 2; j < n; j++)
if (!a[i - 1][j - 1])
{
maxRow++;
maxCol[j]++;
int ii = i - maxCol[j] + 1, jj = j - maxRow + 1;
ans += getSum(ii - 1, jj - 1, i, j) == 0 &&
getSum(ii - 2, jj - 1, ii - 1, j) == maxRow &&
getSum(i, jj - 1, i + 1, j) == maxRow &&
getSum(ii - 1, jj - 2, i, jj - 1) == maxCol[j] &&
getSum(ii - 1, j, i, j + 1) == maxCol[j];
}
else maxRow = maxCol[j] = 0;
}
return ans;
}
long long count_rectangles(vector<vector<int>> _a)
{
a = _a;
m = a.size();
n = a[0].size();
// if (m == 3)
// return subtask5();
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
if (a[i][j] > 1)
return 0;
return subtask6();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |