이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 250;
int n,m;
int col[N][N][N],row[N][N][N];
long long count_rectangles(std::vector<std::vector<int> > a) {
n = a.size();
m = a[0].size();
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
int mx = 0;
for(int k=j+1;k<m;k++){
if(k-j>1&&mx<a[i][j]&&mx<a[i][k])
row[j][k][i]++;
mx = max(mx,a[i][k]);
}
}
for(int i=0;i<m;i++)
for(int j=0;j<n;j++){
int mx = 0;
for(int k=j+1;k<n;k++){
if(k-j>1&&mx<a[j][i]&&mx<a[k][i])
col[j][k][i]++;
if(i)
col[j][k][i] += col[j][k][i-1];
mx = max(mx,a[k][i]);
}
}
LL ans = 0;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
for(int k=j+1;k<m;k++){
int q = 1;
for(int k1 = i+1;k1<n;k1++){
if(k1-i>1&&k-j>1)
ans += q&(col[i][k1][k-1]-col[i][k1][j]==(k-j-1));
q &= row[j][k][k1];
}
}
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... |