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> > mat) {
const int r = mat.size();
const int c = mat[0].size();
if (r <= 2) {
return 0;
}
if (c <= 2) {
return 0;
}
// Subtask #1 && Subtask #2
long long res = 0;
for (int i = 1; i < r - 1; i++) {
for (int j = 1; j < c - 1; j++) {
bitset<100> valid;
valid.set();
for (int x = i; x < r - 1; x++) {
int mx = 0;
vector<int> col_max(c);
for (int z = j; z < c - 1; z++) {
const int L = mat[x][j - 1];
const int R = mat[x][z + 1];
mx = max(mx, mat[x][z]);
col_max[z] = max(col_max[z], mat[x][z]);
if (mx >= L || mx >= R) {
valid[z] = 0;
continue;
}
const int up = mat[i - 1][z];
const int down = mat[x + 1][z];
if (col_max[z] >= up || col_max[z] >= down) {
continue;
}
if (!valid[z]) 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... |