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;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#include "rect.h"
int N, M;
int grid[2505][2505];
bool check(int x0, int x1, int y0, int y1) {
for (int i = x0; i <= x1; i++) {
for (int j = y0; j <= y1; j++) {
int h0 = grid[i][j];
int h1 = grid[i][y0 - 1];
int h2 = grid[i][y1 + 1];
int h3 = grid[x0 - 1][j];
int h4 = grid[x1 + 1][j];
if (h0 >= h1 || h0 >= h2 || h0 >= h3 || h0 >= h4)
return false;
}
}
return true;
}
ll count_rectangles(vector<vi> a) {
N = a.size();
M = a[0].size();
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
grid[i][j] = a[i][j];
}
}
int total = 0;
for (int x0 = 1; x0 <= N - 2; x0++) {
for (int x1 = x0; x1 <= N - 2; x1++) {
for (int y0 = 1; y0 <= M - 2; y0++) {
for (int y1 = y0; y1 <= M - 2; y1++) {
if (check(x0, x1, y0, y1))
total++;
}
}
}
}
return total;
}
# | 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... |