#include "rect.h"
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(int i=a;i<=(b - 1);i++)
using namespace std;
ll count_rectangles(vector<vector<int>> a) {
int n = a.size(), m = a[0].size();
ll ans = 0;
FOR(a1, 1, n - 1)
{
FOR(b1, 1, m - 1)
{
FOR(a2, a1, n - 1)
{
if(a[a2][b1] >= a[a1 - 1][b1] || a[a2][b1] >= a[a2][b1 - 1])
break;
int further = 0;
FOR(b2, b1, m - 1)
{
if(further)
break;
int can = 1;
FOR(i, a1, a2 + 1)
{
if(!can)
break;
FOR(j, b1, b2 + 1)
{
if(!can)
break;
if(a[i][j] >= a[a1 - 1][j] || a[i][j] >= a[i][b1 - 1] || a[i][j] >= a[a2 + 1][j] || a[i][j] >= a[i][b2 + 1])
can = 0;
if(!can)
further = (a[i][j] >= a[a1 - 1][j] || a[i][j] >= a[i][b1 - 1] || a[i][j] >= a[a2 + 1][j]);
}
}
ans += can;
}
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
15 ms |
380 KB |
Output is correct |
23 |
Correct |
15 ms |
400 KB |
Output is correct |
24 |
Correct |
15 ms |
388 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
304 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
15 ms |
380 KB |
Output is correct |
18 |
Correct |
15 ms |
400 KB |
Output is correct |
19 |
Correct |
15 ms |
388 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
606 ms |
824 KB |
Output is correct |
31 |
Correct |
541 ms |
824 KB |
Output is correct |
32 |
Correct |
699 ms |
904 KB |
Output is correct |
33 |
Correct |
2 ms |
596 KB |
Output is correct |
34 |
Correct |
3 ms |
724 KB |
Output is correct |
35 |
Correct |
3 ms |
820 KB |
Output is correct |
36 |
Correct |
3 ms |
800 KB |
Output is correct |
37 |
Correct |
4 ms |
816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
15 ms |
380 KB |
Output is correct |
18 |
Correct |
15 ms |
400 KB |
Output is correct |
19 |
Correct |
15 ms |
388 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
606 ms |
824 KB |
Output is correct |
26 |
Correct |
541 ms |
824 KB |
Output is correct |
27 |
Correct |
699 ms |
904 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
3 ms |
724 KB |
Output is correct |
30 |
Correct |
3 ms |
820 KB |
Output is correct |
31 |
Correct |
3 ms |
800 KB |
Output is correct |
32 |
Correct |
4 ms |
816 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
15 ms |
7208 KB |
Output is correct |
39 |
Correct |
579 ms |
7304 KB |
Output is correct |
40 |
Correct |
289 ms |
7212 KB |
Output is correct |
41 |
Correct |
18 ms |
7192 KB |
Output is correct |
42 |
Execution timed out |
5021 ms |
7340 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
404 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
392 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
57 ms |
28364 KB |
Output is correct |
8 |
Correct |
145 ms |
61176 KB |
Output is correct |
9 |
Correct |
124 ms |
61516 KB |
Output is correct |
10 |
Correct |
131 ms |
61688 KB |
Output is correct |
11 |
Correct |
43 ms |
30504 KB |
Output is correct |
12 |
Correct |
75 ms |
57748 KB |
Output is correct |
13 |
Correct |
80 ms |
61504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
15 ms |
380 KB |
Output is correct |
18 |
Correct |
15 ms |
400 KB |
Output is correct |
19 |
Correct |
15 ms |
388 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
606 ms |
824 KB |
Output is correct |
26 |
Correct |
541 ms |
824 KB |
Output is correct |
27 |
Correct |
699 ms |
904 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
3 ms |
724 KB |
Output is correct |
30 |
Correct |
3 ms |
820 KB |
Output is correct |
31 |
Correct |
3 ms |
800 KB |
Output is correct |
32 |
Correct |
4 ms |
816 KB |
Output is correct |
33 |
Correct |
15 ms |
7208 KB |
Output is correct |
34 |
Correct |
579 ms |
7304 KB |
Output is correct |
35 |
Correct |
289 ms |
7212 KB |
Output is correct |
36 |
Correct |
18 ms |
7192 KB |
Output is correct |
37 |
Execution timed out |
5021 ms |
7340 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |