This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long count_rectangles(vector<vector<int>> a) {
int n = a.size();
int m = a[0].size();
if (n < 3 || m < 3) return 0;
long long tot = 0;
for (int i = 1; i < n-1; i++) {
for (int j = 1; j < m-1; j++) {
vector<vector<int>> r(n, vector<int> (m));
vector<vector<int>> col(n, vector<int> (m));
for (int b = i; b < n-1; b++) {
for (int c = j; c < m-1; c++) {
r[b][c] = max(r[b][c-1], a[b][c]);
col[b][c] = max(col[b-1][c], a[b][c]);
}
}
vector<vector<int>> f(n, vector<int> (m, 0));
for (int t = 0; t < m; t++) f[i-1][t] = 1;
for (int b = i; b < n-1; b++) {
for (int c = j; c < m-1; c++) {
if (a[i-1][c] <= col[b][c]) break;
if (a[b][j-1] <= r[b][c]) break;
if (a[b][c+1] <= r[b][c]) continue;
f[b][c] = 1;
if (a[b+1][c] <= col[b][c]) break;
if (!f[b-1][c]) continue;
tot++;
}
}
}
}
return tot;
}
# | 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... |