Submission #1104126

#TimeUsernameProblemLanguageResultExecution timeMemory
1104126ezzzayFancy Fence (CEOI20_fancyfence)C++14
12 / 100
92 ms57316 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...