Submission #972041

# Submission time Handle Problem Language Result Execution time Memory
972041 2024-04-29T19:20:09 Z opPO Rectangles (IOI19_rect) C++14
37 / 100
5000 ms 22876 KB
#include "rect.h"
#include <bits/stdc++.h>

#define sz(x) (int)x.size()

using namespace std;

long long count_rectangles(vector<vector<int>> a) {
    int n = sz(a);
    int m = sz(a[0]);

    if (n <= 2 || m <= 2) {
        return 0;
    }
    if (n == 3) {
        long long res = 0;
        for (int l = 0; l < m; l++) {
            int mx = -1e9;
            for (int r = l + 1; r < m; r++) {
                if (r - l > 1 && mx < a[1][l] && mx < a[1][r]) {
                    res++;
                }
                if (a[1][r] >= a[0][r] || a[1][r] >= a[2][r]) break;
                mx = max(mx, a[1][r]);
            }
        }

        return res;
    }

    long long res = 0;
    for (int r1 = 1; r1 < n - 1; r1++) {
        for (int r2 = r1; r2 < n - 1; r2++) {
            for (int c1 = 1; c1 < m - 1; c1++) {
                for (int c2 = c1; c2 < m - 1; c2++) {
                    bool ok = 1;

                    for (int i = r1; i <= r2; i++) {
                        if (!ok) break;
                        for (int j = c1; j <= c2; j++) {
                            if (a[i][j] >= a[r1 - 1][j] || a[i][j] >= a[r2 + 1][j]
                                || a[i][j] >= a[i][c1 - 1] || a[i][j] >= a[i][c2 + 1]) {
                                ok = 0;
                                break;
                            }
                        }
                    }

                    res += ok;
                }
            }
        }
    }

    assert(res <= 1ll * n * m);

    return res;
}

/*
g++ -std=gnu++14 -O2 -Wall -pipe -static -o "rect" "grader.cpp" "rect.cpp"
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 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 600 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 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 36 ms 348 KB Output is correct
23 Correct 32 ms 600 KB Output is correct
24 Correct 34 ms 348 KB Output is correct
25 Correct 21 ms 348 KB Output is correct
26 Correct 26 ms 480 KB Output is correct
27 Correct 26 ms 348 KB Output is correct
28 Correct 26 ms 484 KB Output is correct
29 Correct 7 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 600 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 344 KB Output is correct
17 Correct 36 ms 348 KB Output is correct
18 Correct 32 ms 600 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
20 Correct 21 ms 348 KB Output is correct
21 Correct 26 ms 480 KB Output is correct
22 Correct 26 ms 348 KB Output is correct
23 Correct 26 ms 484 KB Output is correct
24 Correct 7 ms 600 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 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 1215 ms 736 KB Output is correct
31 Correct 1237 ms 732 KB Output is correct
32 Correct 1203 ms 736 KB Output is correct
33 Correct 759 ms 604 KB Output is correct
34 Correct 987 ms 856 KB Output is correct
35 Correct 975 ms 740 KB Output is correct
36 Correct 980 ms 852 KB Output is correct
37 Correct 921 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 344 KB Output is correct
17 Correct 36 ms 348 KB Output is correct
18 Correct 32 ms 600 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
20 Correct 21 ms 348 KB Output is correct
21 Correct 26 ms 480 KB Output is correct
22 Correct 26 ms 348 KB Output is correct
23 Correct 26 ms 484 KB Output is correct
24 Correct 7 ms 600 KB Output is correct
25 Correct 1215 ms 736 KB Output is correct
26 Correct 1237 ms 732 KB Output is correct
27 Correct 1203 ms 736 KB Output is correct
28 Correct 759 ms 604 KB Output is correct
29 Correct 987 ms 856 KB Output is correct
30 Correct 975 ms 740 KB Output is correct
31 Correct 980 ms 852 KB Output is correct
32 Correct 921 ms 720 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 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 5046 ms 4188 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 496 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 600 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 600 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 1 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 5054 ms 22876 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 600 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 344 KB Output is correct
17 Correct 36 ms 348 KB Output is correct
18 Correct 32 ms 600 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
20 Correct 21 ms 348 KB Output is correct
21 Correct 26 ms 480 KB Output is correct
22 Correct 26 ms 348 KB Output is correct
23 Correct 26 ms 484 KB Output is correct
24 Correct 7 ms 600 KB Output is correct
25 Correct 1215 ms 736 KB Output is correct
26 Correct 1237 ms 732 KB Output is correct
27 Correct 1203 ms 736 KB Output is correct
28 Correct 759 ms 604 KB Output is correct
29 Correct 987 ms 856 KB Output is correct
30 Correct 975 ms 740 KB Output is correct
31 Correct 980 ms 852 KB Output is correct
32 Correct 921 ms 720 KB Output is correct
33 Execution timed out 5046 ms 4188 KB Time limit exceeded
34 Halted 0 ms 0 KB -