Submission #1077417

# Submission time Handle Problem Language Result Execution time Memory
1077417 2024-08-27T07:01:16 Z Ignut Rectangles (IOI19_rect) C++17
37 / 100
3637 ms 1048576 KB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int INF = 1e9 + 123;

ll count_rectangles(vector<vector<int>> a) {
    int n = a.size(), m = a[0].size();
    int min_h[n][m], max_h[n][m], min_v[n][m], max_v[n][m];
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < m; j ++) {
            for (int ii = i; ii >= 0; ii --) {
                if (a[ii][j] > a[i][j]) break;
                min_v[i][j] = ii;
            }
            for (int ii = i; ii < n; ii ++) {
                if (a[ii][j] > a[i][j]) break;
                max_v[i][j] = ii;
            }
            for (int jj = j; jj >= 0; jj --) {
                if (a[i][jj] > a[i][j]) break;
                min_h[i][j] = jj;
            }
            for (int jj = j; jj < m; jj ++) {
                if (a[i][jj] > a[i][j]) break;
                max_h[i][j] = jj;
            }
        }
    }
    int minH[m][n][n], maxH[m][n][n], minV[m][n][n], maxV[m][n][n];
    for (int j = 0; j < m; j ++) {
        for (int l = 0; l < n; l ++) {
            minH[j][l][l] = min_h[l][j];
            maxH[j][l][l] = max_h[l][j];
            minV[j][l][l] = min_v[l][j];
            maxV[j][l][l] = max_v[l][j];
            for (int r = l + 1; r < n; r ++) {
                minH[j][l][r] = min(minH[j][l][r - 1], min_h[r][j]);
                maxH[j][l][r] = max(maxH[j][l][r - 1], max_h[r][j]);
                minV[j][l][r] = min(minV[j][l][r - 1], min_v[r][j]);
                maxV[j][l][r] = max(maxV[j][l][r - 1], max_v[r][j]);
            }
        }
    }

    int res = 0;
    for (int u = 1; u < n - 1; u ++) {
        for (int d = u; d < n - 1; d ++) {
            for (int l = 1; l < m - 1; l ++) {
                int mnh = INF, mxh = -INF, mnv = INF, mxv = -INF;
                for (int r = l; r < m - 1; r ++) {
                    mnh = min(mnh, minH[r][u][d]);
                    mxh = max(mxh, maxH[r][u][d]);
                    mnv = min(mnv, minV[r][u][d]);
                    mxv = max(mxv, maxV[r][u][d]);
                    res += (mnh == l && mxh == r && mnv == u && mxv == d);
                }
            }
        } 
    }

    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 67 ms 8612 KB Output is correct
23 Correct 68 ms 8536 KB Output is correct
24 Correct 68 ms 8536 KB Output is correct
25 Correct 68 ms 8536 KB Output is correct
26 Correct 55 ms 8280 KB Output is correct
27 Correct 69 ms 8512 KB Output is correct
28 Correct 68 ms 8536 KB Output is correct
29 Correct 20 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 67 ms 8612 KB Output is correct
18 Correct 68 ms 8536 KB Output is correct
19 Correct 68 ms 8536 KB Output is correct
20 Correct 68 ms 8536 KB Output is correct
21 Correct 55 ms 8280 KB Output is correct
22 Correct 69 ms 8512 KB Output is correct
23 Correct 68 ms 8536 KB Output is correct
24 Correct 20 ms 4696 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 2197 ms 126820 KB Output is correct
31 Correct 2198 ms 126812 KB Output is correct
32 Correct 2183 ms 126804 KB Output is correct
33 Correct 2199 ms 126680 KB Output is correct
34 Correct 2317 ms 126752 KB Output is correct
35 Correct 2219 ms 126660 KB Output is correct
36 Correct 2194 ms 126656 KB Output is correct
37 Correct 1926 ms 124400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 67 ms 8612 KB Output is correct
18 Correct 68 ms 8536 KB Output is correct
19 Correct 68 ms 8536 KB Output is correct
20 Correct 68 ms 8536 KB Output is correct
21 Correct 55 ms 8280 KB Output is correct
22 Correct 69 ms 8512 KB Output is correct
23 Correct 68 ms 8536 KB Output is correct
24 Correct 20 ms 4696 KB Output is correct
25 Correct 2197 ms 126820 KB Output is correct
26 Correct 2198 ms 126812 KB Output is correct
27 Correct 2183 ms 126804 KB Output is correct
28 Correct 2199 ms 126680 KB Output is correct
29 Correct 2317 ms 126752 KB Output is correct
30 Correct 2219 ms 126660 KB Output is correct
31 Correct 2194 ms 126656 KB Output is correct
32 Correct 1926 ms 124400 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 860 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Runtime error 763 ms 1048576 KB Execution killed with signal 9
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 856 KB Output is correct
2 Correct 11 ms 1112 KB Output is correct
3 Correct 17 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 12 ms 860 KB Output is correct
6 Correct 11 ms 860 KB Output is correct
7 Correct 11 ms 860 KB Output is correct
8 Correct 11 ms 860 KB Output is correct
9 Correct 15 ms 1024 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 604 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 860 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Runtime error 3637 ms 1048576 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 67 ms 8612 KB Output is correct
18 Correct 68 ms 8536 KB Output is correct
19 Correct 68 ms 8536 KB Output is correct
20 Correct 68 ms 8536 KB Output is correct
21 Correct 55 ms 8280 KB Output is correct
22 Correct 69 ms 8512 KB Output is correct
23 Correct 68 ms 8536 KB Output is correct
24 Correct 20 ms 4696 KB Output is correct
25 Correct 2197 ms 126820 KB Output is correct
26 Correct 2198 ms 126812 KB Output is correct
27 Correct 2183 ms 126804 KB Output is correct
28 Correct 2199 ms 126680 KB Output is correct
29 Correct 2317 ms 126752 KB Output is correct
30 Correct 2219 ms 126660 KB Output is correct
31 Correct 2194 ms 126656 KB Output is correct
32 Correct 1926 ms 124400 KB Output is correct
33 Runtime error 763 ms 1048576 KB Execution killed with signal 9
34 Halted 0 ms 0 KB -