이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops")
#include "rect.h"
#include <bits/stdc++.h>
#define ll long long
#define N 805
using namespace std;
int arr[N][N],n,m,mx[N];
long long count_rectangles(std::vector<std::vector<int> > a) {
n=a.size(); m=a[0].size();
ll ans=0;
for (int i=0;i<n;i++){
for (int j=0;j<m;j++)
arr[i][j]=a[i][j];
}
for (int i=1;i<n-1;i++){
for (int j=1;j<m-1;j++){
for (int k=j;k<m-1;k++){
for (int l=j;l<=k;l++)
mx[l]=0;
for (int l=i;l<n-1;l++){
int lmx=0,add=1;
for (int h=j;h<=k;h++){
lmx=max(lmx,arr[l][h]);
mx[h]=max(mx[h],arr[l][h]);
if (mx[h]>=arr[i-1][h]||mx[h]>=arr[l+1][h])
add=0;
}
if (lmx>=arr[l][j-1]||lmx>=arr[l][k+1])
break;
// cout<<"add "<<i<<"~"<<l<<" , "<<j<<"~"<<k<<" : "<<add<<'\n';
ans+=add;
}
}
}
}
return ans;
}
/*
4 4
3 3 3 3
3 1 2 3
4 2 3 4
4 4 4 4
*/
# | 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... |