This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Author: Kajetan Ramsza
#include "rect.h"
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#ifdef DEBUG
auto& operator<<(auto& os, const pair<auto, auto> &p);
auto& operator<<(auto &os, const auto &v)
{ os<<"{"; for(auto it=begin(v);it!=end(v);++it) {
if(it != begin(v)) { os<<", "; } os<<(*it);
} return os<<"}"; }
auto& operator<<(auto &os, const pair<auto, auto> &p)
{ return os<<"("<<p.first<<", "<<p.second<<")"; }
void dbg_out(auto... x) { ((cerr<<' '<<x), ...) << endl; }
#define dbg(x...) cerr<<"("<<#x<<"):", dbg_out(x)
#else
#define dbg(...)
#endif
int n, m;
bool check(vector<vi> &a, int x1, int x2, int y1, int y2) {
assert(0 < x1 && x1 < x2 && x2 < n);
assert(0 < y1 && y1 < y2 && y2 < m);
rep(i,x1,x2) rep(j,y1,y2)
if(a[x1-1][j] <= a[i][j] || a[x2][j] <= a[i][j] ||
a[i][y1-1] <= a[i][j] || a[i][y2] <= a[i][j])
return false;
return true;
}
ll count_rectangles(vector<vi> a) {
n = sz(a);
m = sz(a[0]);
ll res = 0;
rep(x1,1,n) rep(x2,x1+1,n)
rep(y1,1,m) rep(y2,y1+1,m)
res += check(a,x1,x2,y1,y2);
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... |