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 "rect.h"
#include <bits/stdc++.h>
using namespace std;
long long count_rectangles(vector<vector<int>> a) {
int n = a.size(), m = a[0].size();
long long ans = 0;
for (int x = 1; x < n - 1; ++x) {
for (int y = 1; y < m - 1; ++y) {
for (int i = x; i < n - 1; ++i) {
if (a[i][y] >= a[i][y - 1] || a[i][y] >= a[x - 1][y]) {
break;
}
bool bad = 0;
for (int j = y; j < m - 1 && !bad; ++j) {
bool good = 1;
for (int l = x; l <= i && !bad && good; ++l) {
for (int r = y; r <= j && !bad && good; ++r) {
good &= a[l][r] < a[l][j + 1] && a[l][r] < a[i + 1][r];
bad |= a[l][r] >= a[l][y - 1] || a[l][r] >= a[x - 1][r] || a[l][r] >= a[l + 1][r];
}
}
ans += good;
}
}
}
}
return ans;
}
# | 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... |