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>
#include "rect.h"
using namespace std;
typedef long long ll;
ll n, m;
ll count_rectangles(vector<vector<int>> a) {
if (a.size() <= 2) return 0;
n = a.size(); m = a[0].size();
vector<vector<bool>> vst(n, vector<bool>(m));
ll res = 0;
for (int i = 1; i < n-1; i++) {
for (int j = 1; j < m-1; j++) {
if (a[i][j] || vst[i][j]) continue;
ll ptrN = i, ptrM = j;
while (!a[ptrN][ptrM]) ptrM++;
ptrM--;
while (!a[ptrN][ptrM]) ptrN++;
ptrN--;
bool poss = true;
for (int x = i; x <= ptrN && poss; x++) {
for (int y = j; y <= ptrM && poss; y++) {
vst[x][y] = true;
if (a[x][y]) poss = false;
}
}
for (int x = i; x <= ptrN && poss; x++) {
if (!a[x][j-1]) poss = false;
if (!a[x][ptrM+1]) poss = false;
}
for (int y = j; y <= ptrM && poss; y++) {
if (!a[i-1][y]) poss = false;
if (!a[ptrN+1][y]) poss = false;
}
res += poss;
}
}
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... |