# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891444 | Sir_Ahmed_Imran | Split the Attractions (IOI19_split) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 2500
int l[N][N];
int u[N][N];
int r[N][N];
int d[N][N];
ll count_rectangles(vector<vector<int>> a){
int n,m;
n=a.size();
m=a[0].size();
for(int i=1;i<n-1;i++){
for(int j=1;j<m-1;j++){
l[i][j]=l[i-1][j]+(a[i][j]<a[i][j-1]);
u[i][j]=u[i][j-1]+(a[i][j]<a[i-1][j]);
r[i][j]=r[i-1][j]+(a[i][j]<a[i][j+1]);
d[i][j]=d[i][j-1]+(a[i][j]<a[i+1][j]);
}
}
ll o=0;
for(int i1=1;i1<n-1;i1++){
for(int j1=1;j1<m-1;j1++){
for(int i2=i1;i2<n-1;i2++){
for(int j2=j1;j2<m-1;j2++){
if(l[i2][j1]-l[i1-1][j1]==i2-i1+1
&& u[i1][j2]-u[i1][j1-1]==j2-j1+1
&& r[i2][j2]-r[i1-1][j2]==i2-i1+1
&& d[i2][j2]-d[i2][j1-1]==j2-j1+1){
o++;
}
}
}
}
}
return o;
}