#include "rect.h"
#include<bits/stdc++.h>
using namespace std;
bitset<80> ok[80][80][80];
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][l];
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][l];
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 |
Correct |
3 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
2 ms |
1372 KB |
Output is correct |
5 |
Correct |
2 ms |
1372 KB |
Output is correct |
6 |
Correct |
3 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
2 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
2 ms |
1372 KB |
Output is correct |
5 |
Correct |
2 ms |
1372 KB |
Output is correct |
6 |
Correct |
3 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
2 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
87 ms |
8188 KB |
Output is correct |
23 |
Correct |
93 ms |
8340 KB |
Output is correct |
24 |
Correct |
111 ms |
8276 KB |
Output is correct |
25 |
Correct |
77 ms |
8276 KB |
Output is correct |
26 |
Correct |
74 ms |
8176 KB |
Output is correct |
27 |
Correct |
74 ms |
8168 KB |
Output is correct |
28 |
Correct |
76 ms |
8272 KB |
Output is correct |
29 |
Correct |
22 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
2 ms |
1372 KB |
Output is correct |
5 |
Correct |
2 ms |
1372 KB |
Output is correct |
6 |
Correct |
3 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
87 ms |
8188 KB |
Output is correct |
18 |
Correct |
93 ms |
8340 KB |
Output is correct |
19 |
Correct |
111 ms |
8276 KB |
Output is correct |
20 |
Correct |
77 ms |
8276 KB |
Output is correct |
21 |
Correct |
74 ms |
8176 KB |
Output is correct |
22 |
Correct |
74 ms |
8168 KB |
Output is correct |
23 |
Correct |
76 ms |
8272 KB |
Output is correct |
24 |
Correct |
22 ms |
4444 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
1372 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Runtime error |
1073 ms |
17248 KB |
Execution killed with signal 11 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
2 ms |
1372 KB |
Output is correct |
5 |
Correct |
2 ms |
1372 KB |
Output is correct |
6 |
Correct |
3 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
87 ms |
8188 KB |
Output is correct |
18 |
Correct |
93 ms |
8340 KB |
Output is correct |
19 |
Correct |
111 ms |
8276 KB |
Output is correct |
20 |
Correct |
77 ms |
8276 KB |
Output is correct |
21 |
Correct |
74 ms |
8176 KB |
Output is correct |
22 |
Correct |
74 ms |
8168 KB |
Output is correct |
23 |
Correct |
76 ms |
8272 KB |
Output is correct |
24 |
Correct |
22 ms |
4444 KB |
Output is correct |
25 |
Runtime error |
1073 ms |
17248 KB |
Execution killed with signal 11 |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
3416 KB |
Output is correct |
2 |
Correct |
19 ms |
2908 KB |
Output is correct |
3 |
Correct |
22 ms |
3544 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
22 ms |
3604 KB |
Output is correct |
6 |
Correct |
22 ms |
3416 KB |
Output is correct |
7 |
Correct |
23 ms |
3432 KB |
Output is correct |
8 |
Correct |
22 ms |
3420 KB |
Output is correct |
9 |
Correct |
22 ms |
3420 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 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5095 ms |
23796 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
2 ms |
1372 KB |
Output is correct |
5 |
Correct |
2 ms |
1372 KB |
Output is correct |
6 |
Correct |
3 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
87 ms |
8188 KB |
Output is correct |
18 |
Correct |
93 ms |
8340 KB |
Output is correct |
19 |
Correct |
111 ms |
8276 KB |
Output is correct |
20 |
Correct |
77 ms |
8276 KB |
Output is correct |
21 |
Correct |
74 ms |
8176 KB |
Output is correct |
22 |
Correct |
74 ms |
8168 KB |
Output is correct |
23 |
Correct |
76 ms |
8272 KB |
Output is correct |
24 |
Correct |
22 ms |
4444 KB |
Output is correct |
25 |
Runtime error |
1073 ms |
17248 KB |
Execution killed with signal 11 |
26 |
Halted |
0 ms |
0 KB |
- |