Submission #941446

# Submission time Handle Problem Language Result Execution time Memory
941446 2024-03-09T00:58:34 Z Programmer123 Rectangles (IOI19_rect) C++17
37 / 100
5000 ms 61264 KB
#include "rect.h"

long long count_rectangles(std::vector<std::vector<int> > a) {
    int N = a.size();
    int M = a[0].size();
    long long ans = 0;
    if (N == 3) {
        bool works[M];
        works[0] = false;
        works[M - 1] = false;
        for (int i = 1; i < M - 1; ++i) {
            works[i] = a[1][i] < a[0][i] && a[1][i] < a[2][i];
        }
        for (int l = 1; l < M - 1; ++l) {
            if (!works[l]) continue;
            int max = a[1][l];
            for (int r = l; r < M - 1; ++r) {
                if (!works[r]) break;
                max = std::max(max, a[1][r]);
                if (max >= a[1][l - 1]) break;
                if (max >= a[1][r + 1]) continue;
                ans++;
            }
        }
        return ans;
    }
    int max[N];
    for (int u = 1; u < N - 1; ++u) {
        int maxc[M];
        for (int i = 0; i < M; ++i) {
            maxc[i] = a[u][i];
        }
        for (int d = u; d < N - 1; ++d) {
            for (int i = 0; i < M; ++i) {
                maxc[i] = std::max(maxc[i], a[d][i]);
            }
            bool works[M];
            for (int i = 0; i < M; ++i) {
                works[i] = maxc[i] < a[u - 1][i] && maxc[i] < a[d + 1][i];
            }
            for (int l = 1; l < M - 1; ++l) {
                if (!works[l]) continue;
                for (int i = u; i <= d; ++i) {
                    max[i] = a[i][l];
                }
                for (int r = l; r < M - 1; ++r) {
                    if (!works[r]) break;
                    for (int i = u; i <= d; ++i) {
                        max[i] = std::max(max[i], a[i][r]);
                    }
                    for (int i = u; i <= d; ++i) {
                        if (max[i] >= a[i][l - 1]) goto dead;
                    }
                    for (int i = u; i <= d; ++i) {
                        if (max[i] >= a[i][r + 1]) goto next;
                    }
                    ans++;
                    next:;
                }
                dead:;
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 416 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 424 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 348 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 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 416 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 424 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 14 ms 348 KB Output is correct
23 Correct 14 ms 348 KB Output is correct
24 Correct 14 ms 512 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 416 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 14 ms 348 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 14 ms 512 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 424 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 565 ms 944 KB Output is correct
31 Correct 567 ms 944 KB Output is correct
32 Correct 572 ms 1108 KB Output is correct
33 Correct 9 ms 604 KB Output is correct
34 Correct 11 ms 860 KB Output is correct
35 Correct 11 ms 860 KB Output is correct
36 Correct 11 ms 860 KB Output is correct
37 Correct 11 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 416 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 14 ms 348 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 14 ms 512 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 565 ms 944 KB Output is correct
26 Correct 567 ms 944 KB Output is correct
27 Correct 572 ms 1108 KB Output is correct
28 Correct 9 ms 604 KB Output is correct
29 Correct 11 ms 860 KB Output is correct
30 Correct 11 ms 860 KB Output is correct
31 Correct 11 ms 860 KB Output is correct
32 Correct 11 ms 860 KB Output is correct
33 Correct 0 ms 424 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 Correct 444 ms 7440 KB Output is correct
39 Correct 487 ms 7428 KB Output is correct
40 Correct 445 ms 7428 KB Output is correct
41 Correct 486 ms 7428 KB Output is correct
42 Execution timed out 5093 ms 7512 KB Time limit exceeded
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 3 ms 472 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 424 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 Correct 3205 ms 28656 KB Output is correct
8 Execution timed out 5058 ms 61264 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 416 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 14 ms 348 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 14 ms 512 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 565 ms 944 KB Output is correct
26 Correct 567 ms 944 KB Output is correct
27 Correct 572 ms 1108 KB Output is correct
28 Correct 9 ms 604 KB Output is correct
29 Correct 11 ms 860 KB Output is correct
30 Correct 11 ms 860 KB Output is correct
31 Correct 11 ms 860 KB Output is correct
32 Correct 11 ms 860 KB Output is correct
33 Correct 444 ms 7440 KB Output is correct
34 Correct 487 ms 7428 KB Output is correct
35 Correct 445 ms 7428 KB Output is correct
36 Correct 486 ms 7428 KB Output is correct
37 Execution timed out 5093 ms 7512 KB Time limit exceeded
38 Halted 0 ms 0 KB -