#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
const ll MAXN = 2.5E3+16;
bool vis[MAXN][MAXN];
ll count_rectangles (vector <vi> a) {
ll n = a.size(), m = a[0].size();
ll ans = 0;
for (ll i = 1; i < n-1; i++) {
for (ll j = 1; j < m-1; j++) {
if (vis[i][j] || a[i][j] == 1) continue;
ll minI = i, maxI = i;
ll minJ = j, maxJ = j;
queue <ll> q;
ll cou = 0;
q.push(i);
q.push(j);
while (q.size()) {
ll i = q.front(); q.pop();
ll j = q.front(); q.pop();
if (a[i][j] == 1) continue;
if (vis[i][j]) continue;
vis[i][j] = true; cou++;
minI = min(minI, i); maxI = max(maxI, i); minJ = min(minJ, j); maxJ = max(maxJ, j);
if (i-1 >= 0) { q.push(i-1); q.push(j); }
if (j-1 >= 0) { q.push(i); q.push(j-1); }
if (i+1 < n) { q.push(i+1); q.push(j); }
if (j+1 < m) { q.push(i); q.push(j+1); }
}
if (0 < minI && maxI < n-1 && 0 < minJ && maxJ < m-1)
ans += (cou == (maxI-minI+1)*(maxJ-minJ+1));
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
163 ms |
31640 KB |
Output is correct |
3 |
Correct |
295 ms |
67408 KB |
Output is correct |
4 |
Correct |
316 ms |
67716 KB |
Output is correct |
5 |
Correct |
323 ms |
67792 KB |
Output is correct |
6 |
Correct |
149 ms |
33776 KB |
Output is correct |
7 |
Correct |
353 ms |
64172 KB |
Output is correct |
8 |
Correct |
368 ms |
67844 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
448 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |