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 <bits/stdc++.h>
using namespace std;
long long count_rectangles(std::vector<std::vector<int>> a)
{
long long n = a.size();
long long m = a[0].size();
bool isgoodHorizontal[n][m][m];
for (int i = 1; i < n - 1; i++)
{
for (int j = 1; j < m - 1; j++)
{
for (int k = j; k < m - 1; k++)
{
isgoodHorizontal[i][j][k] = 0;
}
}
}
for (int i = 1; i < n - 1; i++)
{
for (int j = 1; j < m - 1; j++)
{
priority_queue<int> hi;
for (int k = j; k < m - 1; k++)
{
hi.push(a[i][k]);
if (a[i][j - 1] <= hi.top())
break;
if (a[i][k + 1] <= hi.top())
continue;
isgoodHorizontal[i][j][k] = 1;
}
}
}
bool isgoodVertical[m][n][n];
for (int i = 1; i < m - 1; i++)
{
for (int j = 1; j < n - 1; j++)
{
for (int k = j; k < n - 1; k++)
{
isgoodVertical[i][j][k] = 0;
}
}
}
for (int i = 1; i < m - 1; i++)
{
for (int j = 1; j < n - 1; j++)
{
priority_queue<int> hi;
for (int k = j; k < n - 1; k++)
{
hi.push(a[k][i]);
if (a[j - 1][i] <= hi.top())
break;
if (a[k + 1][i] <= hi.top())
continue;
isgoodVertical[i][j][k] = 1;
}
}
}
long long res = 0;
for (int i = 1; i < n - 1; i++)
{
for (int j = 1; j < m - 1; j++)
{
bool largeur[m];
fill(largeur+1, largeur + m-1, 0);
for (int a = i; a < n - 1; a++)
{
bool bad2 = false;
for (int b = j; b < m - 1; b++)
{
bool bad = largeur[b];
if (!isgoodHorizontal[a][j][b])
{
bad = true;
largeur[b] = true;
}
if (!isgoodVertical[b][i][a])
{
bad = true;
bad2 = true;
}
if (bad2)
continue;
if (bad)
continue;
res++;
}
}
}
}
return res;
}
# | 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... |