#include "rect.h"
long long count_rectangles(std::vector<std::vector<int> > a) {
int n=a.size(), m=a[0].size();
long long r=0;
for(int r_1=1;r_1<n-1;r_1++){
for(int r_2=r_1;r_2<n-1;r_2++){
for(int c_1=1;c_1<m-1;c_1++){
for(int c_2=c_1;c_2<m-1;c_2++){
bool ok=true;
for(int i=r_1;i<=r_2;i++){
for(int j=c_1;j<=c_2;j++){
ok&=a[i][j]<a[r_1-1][j];
ok&=a[i][j]<a[r_2+1][j];
ok&=a[i][j]<a[i][c_1-1];
ok&=a[i][j]<a[i][c_2+1];
}
}
r+=ok;
}
}
}
}
return r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
420 KB |
Output is correct |
3 |
Correct |
24 ms |
348 KB |
Output is correct |
4 |
Correct |
24 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
420 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
24 ms |
428 KB |
Output is correct |
10 |
Correct |
24 ms |
596 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
24 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
19 |
Correct |
24 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
420 KB |
Output is correct |
3 |
Correct |
24 ms |
348 KB |
Output is correct |
4 |
Correct |
24 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
420 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
24 ms |
428 KB |
Output is correct |
10 |
Correct |
24 ms |
596 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
24 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
19 |
Correct |
24 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Execution timed out |
5027 ms |
348 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
420 KB |
Output is correct |
3 |
Correct |
24 ms |
348 KB |
Output is correct |
4 |
Correct |
24 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
420 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
24 ms |
428 KB |
Output is correct |
10 |
Correct |
24 ms |
596 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
24 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
5027 ms |
348 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
420 KB |
Output is correct |
3 |
Correct |
24 ms |
348 KB |
Output is correct |
4 |
Correct |
24 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
420 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
24 ms |
428 KB |
Output is correct |
10 |
Correct |
24 ms |
596 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
24 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
5027 ms |
348 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3459 ms |
524 KB |
Output is correct |
2 |
Correct |
2071 ms |
504 KB |
Output is correct |
3 |
Correct |
3413 ms |
476 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
3456 ms |
516 KB |
Output is correct |
6 |
Correct |
3392 ms |
516 KB |
Output is correct |
7 |
Correct |
3402 ms |
520 KB |
Output is correct |
8 |
Correct |
3389 ms |
496 KB |
Output is correct |
9 |
Correct |
3370 ms |
520 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
24 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5035 ms |
28412 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
420 KB |
Output is correct |
3 |
Correct |
24 ms |
348 KB |
Output is correct |
4 |
Correct |
24 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
420 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
24 ms |
428 KB |
Output is correct |
10 |
Correct |
24 ms |
596 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
24 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
5027 ms |
348 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |