# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
253567 | Erkhemkhuu | Rectangles (IOI19_rect) | C++17 | 0 ms | 0 KiB |
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 ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
const ll N = 5005;
bool valid(ll x1, ll y1, ll x2, ll y2, vector <vector <ll> > &a) {
for(ll i = x1; i <= x2; i++) {
for(ll j = y1; j <= y2; j++) {
if(a[i][j] >= a[x1 - 1][j]) return false;
if(a[i][j] >= a[x2 + 1][j]) return false;
if(a[i][j] >= a[i][y1 - 1]) return false;
if(a[i][j] >= a[i][y2 + 1]) return false;
}
}
return true;
}
ll count_rectangles(vector <vector <int> > a) {
ll res, i, j, n, m, i1, j1;
res = 0;
n = a.size(); m = a[0].size();
for(i = 1; i < n - 1; i++)
for(j = 1; j < m - 1; j++)
for(i1 = i; i1 < n - 1; i1++)
for(j1 = j; j1 < m - 1; j1++)
res += valid(i, j, i1, j1, a);
return res;
}