| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 396526 | blue | Rectangles (IOI19_rect) | C++17 | 0 ms | 0 KiB |
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 "rect.h"
#include <vector>
using namespace std;
/*
For each (i, j)
T[i][j] = furthest row I such that T[I][j], T[I+1][j], ... T[i-1][j] all have height less than (i, j)
Similarly, D[i][j], R[i][j], L[i][j]
A rectangle (r1, r2, c1, c2) is good if(minD[r1-1][c1..c2] > r2) and so on
*/
long long count_rectangles(vector< vector<int> > a)
{
long long res = 0;
for(int r1 = 1; r1 < n-1; r1++)
{
for(int c1 = 1; c1 < m-1; c1++)
{
for(int r2 = r1; r2 < n-1; r2++)
{
for(int c2 = c1; c2 < m-1; c2++)
{
bool flag = 1;
for(int i = r1; i <= r2; i++)
for(int j = c1; j <= c2; j++)
flag &= (a[i][j] < a[i][c1-1]) && (a[i][j] < a[i][c1+1]) && (a[i][j] < a[r1-1][j]) && (a[i][j] < a[r1+1][j]);
if(flag) res++;
}
}
}
}
return res;
}
