#include <cstdio>
#include <unistd.h>
#include <cassert>
#include<bits/stdc++.h>
using namespace std;
#define Int long long
#define fore(i , n) for(int i = 0 ; i<n;i++)
#define forr(i , x , y) for(int i = x ; i<=y;i++)
#define pb push_back
#define forn(i , x , y) for(int i = x ; i >= y; i--)
class InputReader {
private:
static const int SIZE = 4096;
int inputFileDescriptor;
char buf[SIZE];
int curChar;
int numChars;
public:
inline InputReader(int _inputFileDescriptor):
inputFileDescriptor(_inputFileDescriptor),
curChar(0),
numChars(0) {
}
inline void close() {
::close(inputFileDescriptor);
}
inline char read() {
assert(numChars != -1);
if (curChar >= numChars) {
curChar = 0;
numChars = ::read(inputFileDescriptor, buf, SIZE);
if (numChars == -1)
return -1;
}
return buf[curChar++];
}
inline int readInt() {
int c = eatWhite();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
assert(c >= '0' && c <= '9');
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
inline string readString() {
char c = eatWhite();
string res;
do {
res += c;
c = read();
} while (!isSpaceChar(c));
return res;
}
inline string readLine() {
string res;
while (true) {
char c = read();
if (c == '\n' || c == '\r' || c == -1)
break;
res += c;
}
return res;
}
inline char eatWhite() {
char c = read();
while (isSpaceChar(c))
c = read();
return c;
}
static inline bool isSpaceChar(char c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
};
long long count_rectangles(std::vector<std::vector<int> > a) {
int n = (int)a.size();
int m = (int)a[0].size();
Int ans = 0;
forr(i1 ,1 ,n - 1)
{
forr(j1 ,1, m - 2)
{
forr(i2 ,i1 , n - 2)
{
forr(j2 ,j1 , m - 2)
{
bool acc = 1;
forr(i , i1 , i2)
{
forr(j , j1 , j2)
{
if(a[i][j] >= a[i][j1 - 1] || a[i][j] >= a[i][j2 + 1] || a[i][j] >= a[i1 - 1][j] || a[i][j] >= a[i2 + 1][j])
{
acc = 0;
break;
}
}
if(!acc)
break;
}
ans+=acc;
}
}
}
}
return ans;
}
//int main() {
// InputReader inputReader(STDIN_FILENO);
// int n, m;
// n = inputReader.readInt();
// m = inputReader.readInt();
// vector<vector<int>> a(n, vector<int>(m));
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < m; j++) {
// a[i][j] = inputReader.readInt();
// }
// }
// inputReader.close();
//
// long long result = count_rectangles(a);
//
// printf("%lld\n", result);
// fclose(stdout);
// return 0;
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
33 ms |
348 KB |
Output is correct |
23 |
Correct |
29 ms |
348 KB |
Output is correct |
24 |
Correct |
37 ms |
348 KB |
Output is correct |
25 |
Correct |
18 ms |
344 KB |
Output is correct |
26 |
Correct |
19 ms |
344 KB |
Output is correct |
27 |
Correct |
29 ms |
348 KB |
Output is correct |
28 |
Correct |
19 ms |
348 KB |
Output is correct |
29 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
33 ms |
348 KB |
Output is correct |
18 |
Correct |
29 ms |
348 KB |
Output is correct |
19 |
Correct |
37 ms |
348 KB |
Output is correct |
20 |
Correct |
18 ms |
344 KB |
Output is correct |
21 |
Correct |
19 ms |
344 KB |
Output is correct |
22 |
Correct |
29 ms |
348 KB |
Output is correct |
23 |
Correct |
19 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1105 ms |
732 KB |
Output is correct |
31 |
Correct |
1078 ms |
604 KB |
Output is correct |
32 |
Correct |
1090 ms |
740 KB |
Output is correct |
33 |
Correct |
641 ms |
604 KB |
Output is correct |
34 |
Correct |
772 ms |
600 KB |
Output is correct |
35 |
Correct |
779 ms |
604 KB |
Output is correct |
36 |
Correct |
738 ms |
600 KB |
Output is correct |
37 |
Correct |
724 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
33 ms |
348 KB |
Output is correct |
18 |
Correct |
29 ms |
348 KB |
Output is correct |
19 |
Correct |
37 ms |
348 KB |
Output is correct |
20 |
Correct |
18 ms |
344 KB |
Output is correct |
21 |
Correct |
19 ms |
344 KB |
Output is correct |
22 |
Correct |
29 ms |
348 KB |
Output is correct |
23 |
Correct |
19 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
1105 ms |
732 KB |
Output is correct |
26 |
Correct |
1078 ms |
604 KB |
Output is correct |
27 |
Correct |
1090 ms |
740 KB |
Output is correct |
28 |
Correct |
641 ms |
604 KB |
Output is correct |
29 |
Correct |
772 ms |
600 KB |
Output is correct |
30 |
Correct |
779 ms |
604 KB |
Output is correct |
31 |
Correct |
738 ms |
600 KB |
Output is correct |
32 |
Correct |
724 ms |
600 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Execution timed out |
5087 ms |
4184 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
492 KB |
Output is correct |
6 |
Correct |
10 ms |
348 KB |
Output is correct |
7 |
Correct |
10 ms |
500 KB |
Output is correct |
8 |
Correct |
10 ms |
344 KB |
Output is correct |
9 |
Correct |
13 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
22744 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
33 ms |
348 KB |
Output is correct |
18 |
Correct |
29 ms |
348 KB |
Output is correct |
19 |
Correct |
37 ms |
348 KB |
Output is correct |
20 |
Correct |
18 ms |
344 KB |
Output is correct |
21 |
Correct |
19 ms |
344 KB |
Output is correct |
22 |
Correct |
29 ms |
348 KB |
Output is correct |
23 |
Correct |
19 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
1105 ms |
732 KB |
Output is correct |
26 |
Correct |
1078 ms |
604 KB |
Output is correct |
27 |
Correct |
1090 ms |
740 KB |
Output is correct |
28 |
Correct |
641 ms |
604 KB |
Output is correct |
29 |
Correct |
772 ms |
600 KB |
Output is correct |
30 |
Correct |
779 ms |
604 KB |
Output is correct |
31 |
Correct |
738 ms |
600 KB |
Output is correct |
32 |
Correct |
724 ms |
600 KB |
Output is correct |
33 |
Execution timed out |
5087 ms |
4184 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |