#include "rect.h"
#include<bits/stdc++.h>
using namespace std;
bitset<85> ok[85][85][85];
long long count_rectangles(std::vector<std::vector<int> > a) {
int n=a.size(),m=a[0].size();
int ans=0;
for(int i=1;i<n-1;i++) for(int j=1;j<m-1;j++) {
for(int k=i;k<n-1;k++) for(int l=j;l<m-1;l++)
ok[i][j][k][l]=a[k][l]<min(a[i-1][l],a[k][j-1]);
for(int k=i+1;k<n-1;k++)
ok[i][j][k][j]=ok[i][j][k][j]&ok[i][j][k-1][j];
for(int k=j+1;k<m-1;k++)
ok[i][j][i][k]=ok[i][j][i][k]&ok[i][j][i][k-1];
for(int k=i+1;k<n-1;k++) for(int l=j+1;l<m-1;l++)
ok[i][j][k][l]=ok[i][j][k][l-1]&ok[i][j][k-1][l]&ok[i][j][k][k];
for(int k=i;k;k--) for(int l=j;l;l--)
ok[i][j][k][l]=a[k][l]<min(a[i+1][l],a[k][j+1]);
for(int k=i-1;k;k--)
ok[i][j][k][j]=ok[i][j][k][j]&ok[i][j][k+1][j];
for(int k=j-1;k;k--)
ok[i][j][i][k]=ok[i][j][i][k]&ok[i][j][i][k+1];
for(int k=i-1;k;k--) for(int l=j-1;l;l--)
ok[i][j][k][l]=ok[i][j][k][l+1]&ok[i][j][k+1][l]&ok[i][j][k][k];
ok[i][j][i][j]=a[i][j]<min({a[i][j-1],a[i-1][j],a[i+1][j],a[i][j+1]});
}
for(int i=1;i<n-1;i++)for(int j=1;j<m-1;j++)
for(int k=i;k<n-1;k++) for(int l=j;l<m-1;l++)
ans+=ok[i][j][k][l]&&ok[k][l][i][j];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
3700 KB |
Output is correct |
2 |
Correct |
17 ms |
3220 KB |
Output is correct |
3 |
Correct |
22 ms |
3668 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
24 ms |
3804 KB |
Output is correct |
6 |
Correct |
22 ms |
3612 KB |
Output is correct |
7 |
Correct |
24 ms |
3656 KB |
Output is correct |
8 |
Correct |
26 ms |
3668 KB |
Output is correct |
9 |
Correct |
23 ms |
3684 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
5049 ms |
23608 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |