#include "rect.h"
#include <iostream>
using namespace std;
long long int tag[35][35][35][35],sx,sy,n,m,ans=0,map[1005][1005];
int find(int x,int y)
{
if(x==n-1 || y==m-1)return 0;
int can1=1,can2=1;
//cout<<sx<<" "<<x<<" "<<sy<<" "<<y<<endl;
//cout<<"can1"<<endl;
for(int i=sx;i<=x;i++)
{
long long int ma=0;
for(int j=sy;j<=y;j++)
{
//cout<<i<<" "<<j<<" ";
ma=max(map[i][j],ma);
}
//cout<<endl;
if(ma>=map[i][sy-1] || ma>=map[i][y+1])
{
can1=0;
break;
}
}
//cout<<"can2"<<endl;
for(int j=sy;j<=y;j++)
{
long long int ma=0;
for(int i=sx;i<=x;i++)
{
//cout<<i<<" "<<j<<" ";
ma=max(map[i][j],ma);
}
//cout<<endl;
if(ma>=map[sx-1][j] || ma>=map[x+1][j])
{
can2=0;
break;
}
}
if(can1==1 && can2==1)
{
ans++;
}
if(can2==1 || can1==1)
{
if(can2==1)find(x,y+1);
if(can1==1)find(x+1,y);
}
else find(x+1,y+1);
return 0;
}
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++)map[i][j]=a[i][j];
}
for(int i=1;i<n-1;i++)
{
for(int j=1;j<m-1;j++)
{
sx=i,sy=j;
find(i,j);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
533 ms |
628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
118 ms |
71660 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |