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"
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define s second
#define f first
using namespace std;
typedef pair<int, int> pii;
const int MxN=2510;
int n, m, a[MxN][MxN];
bool v[MxN][MxN];
long long count_rectangles(std::vector<std::vector<int> > A) {
n=A.size(); m=A[0].size();
FOR(i, 0, n) FOR(j, 0, m) a[i][j]=A[i][j];
int ans=0;
FOR(i, 1, n-1) {
FOR(j, 1, m-1) {
if(!v[i][j] && a[i][j]==0) {
int x=i; while(x+1<=n-2 && a[x+1][j]==0) x++;
int y=j; while(y+1<=m-2 && a[i][y+1]==0) y++;
FOR(k, i, x+1) v[k][j]=true;
FOR(l, j, y+1) v[i][l]=true;
bool ok=true;
FOR(k, i, x+1) {
FOR(l, j, y+1) {
ok&=a[k][l]==0;
v[k][l]=true;
if(!ok) break;
}
}
FOR(k, i, x+1) {
ok&=a[k][j-1];
ok&=a[k][y+1];
if(!ok) break;
}
FOR(l, j, y+1) {
ok&=a[i-1][l];
ok&=a[x+1][l];
if(!ok) break;
}
ans+=ok;
}
}
}
return ans;
}
# | 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... |