Submission #824641

#TimeUsernameProblemLanguageResultExecution timeMemory
824641tomrukRectangles (IOI19_rect)C++17
49 / 100
857 ms679188 KiB
#include "rect.h" #include <bits/stdc++.h> #define N 705 using namespace std; short dwn[N][N]; short rght[N][N][N]; long long count_rectangles(vector<vector<int>> a){ long long ans = 0; int n = a.size(); int m = a[0].size(); for(int i = m-1;i>=0;i--){ for(int j = 0;j<n-1;j++){ int maxi = a[j+1][i]; for(int c = j+2;c<n && maxi < a[j][i];c++){ if(maxi >= a[c][i]) continue; rght[j][i][c] = 1; rght[j][i][c] += rght[j][i + 1][c]; maxi = a[c][i]; } } } int cnt = 0; for(int i = n-1;i>0;i--){ for(int j = 0;j<m-1;j++){ int maxi = a[i][j+1]; for(int c = j+2;c<m;c++){ if(maxi >= min(a[i][c],a[i][j])){ dwn[j][c] = 0; continue; } cnt++; dwn[j][c] += 1; maxi = max(maxi,a[i][c]); } for(int c = j+2;c<m;c++){ for(int d = i + 1;d <= i + dwn[j][c];d++){ ans += (j + 1 + rght[i-1][j+1][d]) >= c; } } } } assert(cnt <= n * m); 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...