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>
#define mp make_pair
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int cumsum(int l, int r, vector<int>& a) {
return a[r] - a[l - 1];
}
int n, m;
long long count_rectangles(std::vector<std::vector<int> > a) {
n = a.size(), m = a[0].size();
vector<vector<vector<int> > > colsum(n, vector<vector<int> >(n, vector<int>(m)));
for (int l = 1; l < n - 1; l++) {
for (int r = l; r < n - 1; r++) {
for (int i = 1; i < m - 1; i++) {
int ok = 0;
for (int j = l; j <= r; j++) {
if (a[j][i] >= a[l - 1][i] || a[j][i] >= a[r + 1][i])
ok = 1;
}
colsum[l][r][i] += ok + colsum[l][r][i - 1];
}
}
}
vector<vector<vector<int> > > rowsum(m, vector<vector<int> >(m, vector<int>(n)));
for (int l = 1; l < m - 1; l++) {
for (int r = l; r < m - 1; r++) {
for (int i = 1; i < n - 1; i++) {
int ok = 0;
for (int j = l; j <= r; j++)
if (a[i][j] >= a[i][l - 1] || a[i][j] >= a[i][r + 1])
ok = 1;
rowsum[l][r][i] += ok + rowsum[l][r][i - 1];
}
}
}
int cnt = 0;
for (int i = 1; i < n - 1; i++) {
for (int j = i; j < n - 1; j++) {
for (int k = 1; k < m - 1; k++) {
for (int l = k; l < m - 1; l++) {
if (cumsum(k, l, colsum[i][j]) == 0 and cumsum(i, j, rowsum[k][l]) == 0)
{
cout;
cnt++;
}
}
}
}
}
return cnt;
}
Compilation message (stderr)
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:51:7: warning: statement has no effect [-Wunused-value]
51 | cout;
| ^~~~
# | 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... |