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;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int MAXN = 810;
bool lVal[MAXN][MAXN][MAXN];
bool cVal[MAXN][MAXN][MAXN];
long long count_rectangles(std::vector<std::vector<int> > a) {
int n = a.size();
int m = a[0].size();
for(int i = 1; i < n - 1; i++){
for(int j = 1; j < m - 1; j++){
int maxi = 0;
for(int k = j; k < m - 1; k++){
maxi = max(maxi, a[i][k]);
lVal[i][j][k] = maxi < a[i][j - 1] && maxi < a[i][k + 1];
}
}
}
for(int i = 1; i < m - 1; i++){
for(int j = 1; j < n - 1; j++){
int maxi = 0;
for(int k = j; k < n - 1; k++){
maxi = max(maxi, a[k][i]);
cVal[i][j][k] = maxi < a[j - 1][i] && maxi < a[k + 1][i];
}
}
}
long long ans = 0;
for(int i = 1; i < n - 1; i++){
for(int j = 1; j < m - 1; j++){
for(int k = i; k < n - 1; k++){
for(int l = j; l < m - 1; l++){
if(cVal[l][i][k] == 0) break;
bool flag = true;
for(int x = i; x <= k; x++)
flag &= lVal[x][j][l];
ans += flag;
}
}
}
}
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... |