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 #3
long long res = 0;
const int linha = 1;
for (int i = 1; i < c - 1; i++) {
int cur = 0;
int mx = 0;
for (int j = i; j < c - 1; j++) {
mx = max(mx, mat[linha][j]);
if (mat[linha][j] >= mat[linha - 1][j] || mat[linha][j] >= mat[linha + 1][j]) {
break;
}
if (mx >= mat[linha][i - 1] || mx >= mat[linha][j + 1]) {
continue;
}
++cur;
}
res += cur;
}
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... |