Submission #428543

#TimeUsernameProblemLanguageResultExecution timeMemory
428543HazemRectangles (IOI19_rect)C++14
27 / 100
934 ms199972 KiB
#include "rect.h" #include <bits/stdc++.h> #define LL long long using namespace std; const int N = 250; int n,m; int col[N][N][N],row[N][N][N]; long long count_rectangles(std::vector<std::vector<int> > a) { n = a.size(); m = a[0].size(); for(int i=0;i<n;i++) for(int j=0;j<m;j++){ int mx = 0; for(int k=j+1;k<m;k++){ if(k-j>1&&mx<a[i][j]&&mx<a[i][k]) row[j][k][i]++; mx = max(mx,a[i][k]); } } for(int i=0;i<m;i++) for(int j=0;j<n;j++){ int mx = 0; for(int k=j+1;k<n;k++){ if(k-j>1&&mx<a[j][i]&&mx<a[k][i]) col[j][k][i]++; if(i) col[j][k][i] += col[j][k][i-1]; mx = max(mx,a[k][i]); } } LL ans = 0; for(int i=0;i<n;i++) for(int j=0;j<m;j++) for(int k=j+1;k<m;k++){ int q = 1; for(int k1 = i+1;k1<n;k1++){ if(k1-i>1&&k-j>1) ans += q&(col[i][k1][k-1]-col[i][k1][j]==(k-j-1)); q &= row[j][k][k1]; } } return 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...