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 <bits/stdc++.h>
using namespace std;
long long count_rectangles(vector<vector<int>> a)
{
int n = a.size(), m = a[0].size();
long long ans = 0;
for (int i1 = 1; i1 < n - 1; i1++)
{
for (int j1 = 1; j1 < m - 1; j1++)
{
for (int i2 = i1; i2 < n - 1; i2++)
{
if (a[i2][j1] >= a[i2][j1 - 1] || a[i2][j1] >= a[i1 - 1][j1])
break;
int cont = 0;
for (int j2 = j1; j2 < m - 1; j2++)
{
if (cont == 1)
break;
int can = 1;
for (int x = i1; x <= i2; x++)
{
if (!can)
break;
for (int y = j1; y <= j2; y++)
{
if (!can)
break;
if (a[x][y] >= a[i1 - 1][y] || a[x][y] >= a[i2 + 1][y] || a[x][y] >= a[x][j1 - 1] || a[x][y] >= a[x][j2 + 1])
can = 0;
if (can == 0)
cont = (a[x][y] >= a[i1 - 1][y] || a[x][y] >= a[i2 + 1][y] || a[x][y] >= a[x][j1 - 1]);
}
}
ans += can;
}
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |