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 ll long long
#define fast cin.tie(0);cout.tie(0);
#define order ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);
#define pb push_back
using namespace std;
int n,m,a[2509][2509];
int rec(int x,int y,int x2,int y2)
{
for(int i=x;i<=x2;i++)
{
int mx=0;
for(int j=y;j<=y2;j++)
{
mx=max(mx,a[i][j]);
}
if(mx>=a[i][y-1]||mx>=a[i][y2+1])return 0;
}
for(int j=y;j<=y2;j++)
{
int mx=0;
for(int i=x;i<=x2;i++)
{
mx=max(mx,a[i][j]);
}
if(mx>=a[x-1][j]||mx>=a[x2+1][j])return 0;
}
return 1;
}
ll check(int x,int y)
{
ll ret=0;
for(int i=x;i<n-1;i++)
{
for(int j=y;j<m-1;j++)
{
if(rec(x,y,i,j))ret++;
}
}
return ret;
}
ll ans;
long long count_rectangles(std::vector<std::vector<int> > aa)
{
n=aa.size();m=aa[0].size();
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)a[i][j]=aa[i][j];
}
for(int i=1;i<n-1;i++)
{
for(int j=1;j<m-1;j++)
{
ans+=check(i,j);
}
}
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... |