이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "rect.h"
using namespace std;
const int MAX_W = 205;
const int MAX_N = 2505;
int N, M;
int maxRow[MAX_W][MAX_W][MAX_W];
int maxCol[MAX_W][MAX_W][MAX_W];
long long count_rectangles(vector <vector <int>> a) {
N = a.size(), M = a[0].size();
if(min(N, M) < 3) {
return 0;
}
for(int r = 0; r < N; r++) {
for(int c = 0; c < M; c++) {
maxRow[r][c][c] = a[r][c];
}
for(int sz = 1; sz < M; sz++) {
for(int c1 = 0, c2 = sz; c2 < M; c1++, c2++) {
maxRow[r][c1][c2] = max(maxRow[r][c1 + 1][c2], maxRow[r][c1][c2 - 1]);
}
}
}
for(int c = 0; c < M; c++) {
for(int r = 0; r < N; r++) {
maxCol[c][r][r] = a[r][c];
}
for(int sz = 1; sz < N; sz++) {
for(int r1 = 0, r2 = sz; r2 < N; r1++, r2++) {
maxCol[c][r1][r2] = max(maxCol[c][r1 + 1][r2], maxCol[c][r1][r2 - 1]);
}
}
}
int ans = 0;
for(int r1 = 1; r1 < N - 1; r1++) {
for(int r2 = r1; r2 < N - 1; r2++) {
for(int c1 = 1; c1 < M - 1; c1++) {
bool okCol = true;
for(int c2 = c1; c2 < M - 1; c2++) {
okCol &= (min(a[r1 - 1][c2], a[r2 + 1][c2]) > maxCol[c2][r1][r2]);
bool okRow = true;
for(int r3 = r1; r3 <= r2; r3++) {
okRow &= (min(a[r3][c1 - 1], a[r3][c2 + 1]) > maxRow[r3][c1][c2]);
}
ans += (okCol == true and okRow == true);
}
}
}
}
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... |