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;
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
int h[N];
int w[N];
bool arr[5000][5000];
int ps[5000][5000];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>h[i];
}
for(int i=1;i<=n;i++){
cin>>w[i];
}
int x=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=w[i];j++){
for(int k=1;k<=h[i];k++){
arr[k][x+j]=1;
}
}
x+=w[i];
}
for(int i=1;i<=50;i++){
for(int j=1;j<=50;j++){
ps[i][j]=ps[i-1][j]+ps[i][j-1]-ps[i-1][j-1]+arr[i][j];
}
}
int ans=0;
for(int i=1;i<=50;i++){
for(int j=i;j<=50;j++){
for(int l=1;l<=50;l++){
for(int r=l;r<=50;r++){
int a=ps[r][j]-ps[r][i-1]-ps[l-1][j]+ps[l-1][i-1];
if(a==(j-i+1)*(r-l+1))ans++;
}
}
}
}
cout<<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... |