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;
typedef long long ll;
ll count_rectangles(vector<vector<int>> a) {
int n=a.size(),m=a[0].size();
map<tuple<int,int,int>,int>maximo_fila;
for(int k=1;k<m-1;k++){
for(int i=1;i<n-1;i++){
for(int j=i;j<n-1;j++){
if(j==i){
maximo_fila[{k,i,j}]=a[j][k];
}
else{
maximo_fila[{k,i,j}]=max(a[j][k],maximo_fila[{k,i,j-1}]);
}
}
}
}
map<tuple<int,int,int>,int>maximo_columna;
for(int k=1;k<n-1;k++){
for(int i=1;i<m-1;i++){
for(int j=i;j<m-1;j++){
if(j==i){
maximo_columna[{k,i,j}]=a[k][j];
}
else{
maximo_columna[{k,i,j}]=max(a[k][j],maximo_columna[{k,i,j-1}]);
}
}
}
}
ll rec=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++){
bool posible=true;
for(int fila=i;fila<=j;fila++){
if(maximo_columna[{fila,k,l}]<a[fila][k-1]&&maximo_columna[{fila,k,l}]<a[fila][l+1]){
continue;
}
else{
posible=false;
i=fila+1;
break;
}
}
if(!posible){
continue;
}
for(int columna=k;columna<=l;columna++){
if(maximo_fila[{columna,i,j}]<a[i-1][columna]&&maximo_fila[{columna,i,j}]<a[j+1][columna]){
continue;
}
else{
k=columna+1;
posible=false;
break;
}
}
rec+=(posible);
}
}
}
}
return rec;
}
# | 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... |