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;
for (int i = 1; i < c - 1; i++) {
int cur = 0;
int mn_so_far = 1e9;
const int linha = 1;
for (int j = i; j < c - 1; j++) {
mn_so_far = min(mn_so_far, mat[linha][j]);
if (mat[linha][j] <= mat[linha - 1][j] || mat[linha][j] <= mat[linha + 1][j]) {
break;
}
if (mn_so_far <= mat[linha][i - 1] || mn_so_far <= 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... |