Submission #1043541

#TimeUsernameProblemLanguageResultExecution timeMemory
1043541idasRectangles (IOI19_rect)C++17
10 / 100
1603 ms69516 KiB
#include "rect.h" #include "bits/stdc++.h" #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) #define pb push_back #define s second #define f first using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; const int MxN=2510; int n, m, a[MxN][MxN], mxx[MxN][MxN], mxy[MxN][MxN]; long long count_rectangles(std::vector<std::vector<int> > A) { n=A.size(); m=A[0].size(); FOR(i, 0, n) FOR(j, 0, m) a[i][j]=A[i][j]; int ans=0; FOR(i, 1, n-1) { FOR(j, 1, m-1) { int x=n-2, y=m-2; FOR(k, i, n-1) { if(k>x) break; FOR(l, j, m-1) { if(l>y) break; if(a[k][l]>=a[i-1][l]) { x=k-1; break; } if(a[k][l]>=a[k][j-1]) { y=l-1; break; } if(k-1>=i) mxx[k][l]=max(mxx[k-1][l], a[k][l]); else mxx[k][l]=a[k][l]; if(l-1>=j) mxy[k][l]=max(mxy[k][l-1], a[k][l]); else mxy[k][l]=a[k][l]; bool ok=true; FOR(z, i, k+1) { ok&=mxy[z][l]<a[z][l+1]; } FOR(z, j, l+1) { ok&=mxx[k][z]<a[k+1][z]; } // cout << i << " " << j << " " << k << " " << l << endl; ans+=ok; } } } } 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...