# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147147 | Mamnoon_Siam | Rectangles (IOI19_rect) | C++17 | 5089 ms | 51960 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 "rect.h"
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
const int N = 700;
const int inf = 1e9;
int n, m;
int g[N][N];
bitset<N> ls[N][N];
int mxx[N];
long long count_rectangles(vector<vector<int> > _a) {
n = _a.size(), m = _a[0].size();
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
g[i][j] = _a[i][j];
}
}
for(int i = 1; i < n - 1; i++) {
for(int j = 1; j < m - 1; j++) {
int mx = -inf;
for(int k = j; k > 0; k--) {
mx = max(mx, g[i][k]);
if(mx < g[i][j + 1]) {
if(mx < g[i][k - 1]) {
ls[i][j][k] = 1;
}
} else {
break;
}
}
}
}
int ans = 0;
for(int u = 1; u < n - 1; u++) {
for(int i = 1; i < m - 1; i++) {
mxx[i] = -inf;
}
for(int v = u; v < n - 1; v++) {
bitset<N> can;
for(int i = 1; i < m - 1; i++) {
mxx[i] = max(mxx[i], g[v][i]);
if(mxx[i] < g[u - 1][i] and mxx[i] < g[v + 1][i]) {
can[i] = 1;
}
}
int now = 0;
while(can._Find_next(now) < m - 1) {
int l = can._Find_next(now);
int r = l;
while(can[r + 1]) {
r++;
}
bitset<N> range;
for(int i = l; i <= r; i++) {
range[i] = 1;
}
for(int j = l; j <= r; j++) {
bitset<N> intersection = range;
for(int i = u; i <= v; i++) {
intersection &= ls[i][j];
if(intersection.count() == 0) {
break;
}
}
ans += intersection.count();
}
now = r;
}
}
move_u : ;
}
return ans;
}
Compilation message (stderr)
# | 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... |