이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include<bits/stdc++.h>
using namespace std;
long long count_rectangles(vector<vector<int> > a) {
int n=a.size();
int m=a[0].size();
int ans=0;
int invalrow[n][m][m];
for(int i=0;i<m;i++)for(int j=0;j<m;j++)invalrow[0][i][j]=0;
for(int i=0;i<n;i++){
int colmax[m];memset(colmax,-1,sizeof(colmax));
bool colvalid[m];memset(colvalid,false,sizeof(colvalid));
for(int j=i+2;j<n;j++){
for(int k=0;k<m;k++){
colmax[k]=max(colmax[k],a[j-1][k]);
if(colmax[k]>=a[i][k] || colmax[k]>=a[j][k])colvalid[k]=false;
else colvalid[k]=true;
}
for(int k=0;k<m;k++){
int rowmax[n];memset(rowmax,-1,sizeof(rowmax));
for(int l=k+2;l<n;l++){
if(colvalid[l-1]==false)break;
if(invalrow[j-2][k][l]-invalrow[i][k][l]>0)continue;
bool ok=true;
for(int p=i+1;p<=j-1;p++){
rowmax[p]=max(rowmax[p],a[p][l-1]);
if(rowmax[p]>=a[p][k] || rowmax[p]>=a[p][l]){ok=false;break;}
}
invalrow[j-1][k][l]=invalrow[j-2][k][l];
if(ok)ans++;
else invalrow[j-1][k][l]++;
}
}
}
}
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... |