이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2505;
ll res=0;
int N,M,mat[maxn][maxn],maks[maxn];
bool moze[maxn];
ll prebroj(int x,int y){
ll ret=0;
for(int j=y;j<M;j++){
moze[j]=true;
maks[j]=mat[x][j];
}
for(int i=x;i<N;i++){
int rmaks=0;
for(int j=y;j<M;j++){
rmaks=max(rmaks,mat[i][j]);
moze[j]&=(rmaks<mat[i][y-1] and rmaks<mat[i][j+1]);
}
for(int j=y;j<M;j++)
maks[j]=max(maks[j],mat[i][j]);
for(int j=y;j<M;j++){
if(maks[j]>=mat[i+1][j])
break;
if(maks[j]>=mat[x-1][j])
break;
if(!moze[j])
continue;
ret++;
//cout<<x<<" "<<y<<" "<<i<<" "<<j<<endl;
}
}
return ret;
}
ll count_rectangles(std::vector<std::vector<int> > inp) {
N=inp.size();
M=inp[0].size();
for(int i=1;i<=N;i++)
for(int j=1;j<=M;j++)
mat[i][j]=inp[i-1][j-1];
for(int i=2;i<N;i++)
for(int j=2;j<M;j++)
res+=prebroj(i,j);
return res;
}
# | 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... |