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;
int a[2501][2501];
long long count_rectangles(std::vector<std::vector<int> > A) {
long long ans = 0;
for(int i = 0;i<A.size();i++){
for(int j = 0;j<A[i].size();j++) a[i][j] = A[i][j];
}
int n = A.size();
int m = A[0].size();
map<pair<pair<int,int>,pair<int,int> > ,bool > mp;
for(int i = 1;i<n-1;i++){
for(int j = 1;j<m-1;j++){
for(int k = j;k<m-1;k++){
for(int ii = i;ii<n-1;ii++){
bool f = true;
for(int jj = j;jj<=k;jj++){
if(a[ii][jj]>=a[ii][j-1] || a[ii][jj]>=a[ii][k+1]){
f = false;
break;
}
}
if(!f) break;
pair<int,int> x = {i,j};
pair<int,int> y = {ii,k};
mp[{x,y}] = true;
}
}
}
}
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 jj = j;jj<m-1;jj++){
bool f = true;
for(int ii = i;ii<=k;ii++){
if(a[ii][jj]>=a[i-1][jj] || a[ii][jj]>=a[k+1][jj]){
f = false;
break;
}
}
if(!f) break;
pair<int,int> x = {i,j};
pair<int,int> y = {k,jj};
if(mp[{x,y}]) ans++;
}
}
}
}
return ans;
//return 1;
}
Compilation message (stderr)
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:8:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i<A.size();i++){
~^~~~~~~~~
rect.cpp:9:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0;j<A[i].size();j++) a[i][j] = A[i][j];
~^~~~~~~~~~~~
# | 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... |