#include <bits/stdc++.h>
#include <fstream>
#include "rect.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define pb push_back
#define INF 20000000000
#define fi first
#define se second
//#define cin fin
//#define cout fout
using namespace std;
//double const EPS = 1e-14;
typedef long long ll;
//const ll P = 10007;
const ll mod = 1e9 + 7;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
long long count_rectangles(std::vector<std::vector<int> > a) {
int n = a.size();
int m = a[0].size();
ll cnt = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
for(int w = i; w < n; w++) {
for(int q = j; q < m; q++) {
bool ok = true;
for(int id = i; id <= w; id++) {
if(j-1 >= 0 && a[id][j-1] <= a[id][j]) {
ok = false;
}
else if(j-1 < 0) {
ok = false;
}
if(q+1 < m && a[id][q+1] <= a[id][q]) {
ok = false;
}
else if(q+1 >= m) {
ok = false;
}
}
for(int id = j; id <= q; id++) {
if(i-1 >= 0 && a[i-1][id] <= a[i][id]) {
ok = false;
}
else if(i-1 < 0) {
ok = false;
}
if(w+1 < n && a[w+1][id] <= a[w][id]) {
ok = false;
}
else if(w+1 >= n) {
ok = false;
}
}
if(ok) cnt++;
}
}
}
}
return cnt;
}
# | 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... |