Submission #1067936

# Submission time Handle Problem Language Result Execution time Memory
1067936 2024-08-21T05:47:30 Z becaido Rectangles (IOI19_rect) C++17
27 / 100
323 ms 102740 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifndef WAIMAI
#include "rect.h"
#else
#include "grader.cpp"
#endif

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 205;

int n, m;
ll ans;
int a[SIZE][SIZE];
int U[SIZE][SIZE][SIZE], D[SIZE][SIZE][SIZE];
int L[SIZE][SIZE][SIZE], R[SIZE][SIZE][SIZE];

ll count_rectangles(vector<vector<int>> _a) {
    n = _a.size(), m = _a[0].size();
    FOR (i, 1, n) FOR (j, 1, m) a[i][j] = _a[i - 1][j - 1];

    FOR (i, 1, n) {
        vector<int> st;
        FOR (j, 1, m) {
            while (st.size() && a[i][j] > a[i][st.back()]) st.pop_back();
            L[i][i][j] = (st.size() ? st.back() + 1 : 1);
            st.pb(j);
            // debug(i, j, L[i][i][j]);
        }
        st.clear();
        for (int j = m; j >= 1; j--) {
            while (st.size() && a[i][j] > a[i][st.back()]) st.pop_back();
            R[i][i][j] = (st.size() ? st.back() - 1 : m);
            st.pb(j);
            // debug(i, j, R[i][i][j]);
        }
    }
    FOR (j, 1, m) {
        vector<int> st;
        FOR (i, 1, n) {
            while (st.size() && a[i][j] > a[st.back()][j]) st.pop_back();
            U[i][j][j] = (st.size() ? st.back() + 1 : 1);
            st.pb(i);
            // debug(i, j, U[i][j][j]);
        }
        st.clear();
        for (int i = n; i >= 1; i--) {
            while (st.size() && a[i][j] > a[st.back()][j]) st.pop_back();
            D[i][j][j] = (st.size() ? st.back() - 1 : n);
            st.pb(i);
            // debug(i, j, D[i][j][j]);
        }
    }

    FOR (u, 1, n) FOR (d, u + 1, n) FOR (j, 1, m) {
        L[u][d][j] = max(L[u][d - 1][j], L[d][d][j]);
        R[u][d][j] = min(R[u][d - 1][j], R[d][d][j]);
    }
    FOR (i, 1, n) FOR (l, 1, m) FOR (r, l + 1, m) {
        U[i][l][r] = max(U[i][l][r - 1], U[i][r][r]);
        D[i][l][r] = min(D[i][l][r - 1], D[i][r][r]);
    }

    ans = 0;
    FOR (u, 1, n) FOR (d, u + 2, n) FOR (l, 1, m) FOR (r, l + 2, m) {
        bool f = 1;
        // debug(u, d, l, r, D[u][l][r], U[d][l][r], R[u][d][l], L[u][d][r]);
        f &= (D[u][l + 1][r - 1] + 1 >= d);
        f &= (U[d][l + 1][r - 1] - 1 <= u);
        f &= (R[u + 1][d - 1][l] + 1 >= r);
        f &= (L[u + 1][d - 1][r] - 1 <= l);
        ans += f;
    }
    return ans;
}

/*
in1
6 5
4 8 7 5 6
7 4 10 3 5
9 7 20 14 2
9 14 7 3 6
5 7 5 2 7
4 5 13 5 6
out1
6
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 16220 KB Output is correct
3 Correct 2 ms 16216 KB Output is correct
4 Correct 2 ms 16220 KB Output is correct
5 Correct 3 ms 16216 KB Output is correct
6 Correct 2 ms 16220 KB Output is correct
7 Correct 2 ms 15452 KB Output is correct
8 Correct 1 ms 14684 KB Output is correct
9 Correct 2 ms 16220 KB Output is correct
10 Correct 3 ms 16220 KB Output is correct
11 Correct 2 ms 17848 KB Output is correct
12 Correct 2 ms 16220 KB Output is correct
13 Correct 1 ms 6584 KB Output is correct
14 Correct 1 ms 12636 KB Output is correct
15 Correct 1 ms 10692 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 3 ms 14428 KB Output is correct
20 Correct 2 ms 11612 KB Output is correct
21 Correct 1 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 16220 KB Output is correct
3 Correct 2 ms 16216 KB Output is correct
4 Correct 2 ms 16220 KB Output is correct
5 Correct 3 ms 16216 KB Output is correct
6 Correct 2 ms 16220 KB Output is correct
7 Correct 2 ms 15452 KB Output is correct
8 Correct 1 ms 14684 KB Output is correct
9 Correct 2 ms 16220 KB Output is correct
10 Correct 3 ms 16220 KB Output is correct
11 Correct 2 ms 17848 KB Output is correct
12 Correct 2 ms 16220 KB Output is correct
13 Correct 1 ms 6584 KB Output is correct
14 Correct 1 ms 12636 KB Output is correct
15 Correct 1 ms 10692 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 3 ms 14428 KB Output is correct
20 Correct 2 ms 11612 KB Output is correct
21 Correct 1 ms 10588 KB Output is correct
22 Correct 16 ms 24152 KB Output is correct
23 Correct 16 ms 24156 KB Output is correct
24 Correct 16 ms 25692 KB Output is correct
25 Correct 18 ms 24280 KB Output is correct
26 Correct 17 ms 23896 KB Output is correct
27 Correct 15 ms 24152 KB Output is correct
28 Correct 16 ms 25692 KB Output is correct
29 Correct 7 ms 19036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 16220 KB Output is correct
3 Correct 2 ms 16216 KB Output is correct
4 Correct 2 ms 16220 KB Output is correct
5 Correct 3 ms 16216 KB Output is correct
6 Correct 2 ms 16220 KB Output is correct
7 Correct 2 ms 15452 KB Output is correct
8 Correct 1 ms 14684 KB Output is correct
9 Correct 2 ms 16220 KB Output is correct
10 Correct 3 ms 16220 KB Output is correct
11 Correct 2 ms 17848 KB Output is correct
12 Correct 2 ms 16220 KB Output is correct
13 Correct 1 ms 6584 KB Output is correct
14 Correct 1 ms 12636 KB Output is correct
15 Correct 1 ms 10692 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 16 ms 24152 KB Output is correct
18 Correct 16 ms 24156 KB Output is correct
19 Correct 16 ms 25692 KB Output is correct
20 Correct 18 ms 24280 KB Output is correct
21 Correct 17 ms 23896 KB Output is correct
22 Correct 15 ms 24152 KB Output is correct
23 Correct 16 ms 25692 KB Output is correct
24 Correct 7 ms 19036 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 2 ms 6748 KB Output is correct
27 Correct 3 ms 14428 KB Output is correct
28 Correct 2 ms 11612 KB Output is correct
29 Correct 1 ms 10588 KB Output is correct
30 Correct 297 ms 102364 KB Output is correct
31 Correct 302 ms 102368 KB Output is correct
32 Correct 278 ms 102596 KB Output is correct
33 Correct 283 ms 102548 KB Output is correct
34 Correct 323 ms 102056 KB Output is correct
35 Correct 281 ms 102740 KB Output is correct
36 Correct 281 ms 102224 KB Output is correct
37 Correct 273 ms 101200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 16220 KB Output is correct
3 Correct 2 ms 16216 KB Output is correct
4 Correct 2 ms 16220 KB Output is correct
5 Correct 3 ms 16216 KB Output is correct
6 Correct 2 ms 16220 KB Output is correct
7 Correct 2 ms 15452 KB Output is correct
8 Correct 1 ms 14684 KB Output is correct
9 Correct 2 ms 16220 KB Output is correct
10 Correct 3 ms 16220 KB Output is correct
11 Correct 2 ms 17848 KB Output is correct
12 Correct 2 ms 16220 KB Output is correct
13 Correct 1 ms 6584 KB Output is correct
14 Correct 1 ms 12636 KB Output is correct
15 Correct 1 ms 10692 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 16 ms 24152 KB Output is correct
18 Correct 16 ms 24156 KB Output is correct
19 Correct 16 ms 25692 KB Output is correct
20 Correct 18 ms 24280 KB Output is correct
21 Correct 17 ms 23896 KB Output is correct
22 Correct 15 ms 24152 KB Output is correct
23 Correct 16 ms 25692 KB Output is correct
24 Correct 7 ms 19036 KB Output is correct
25 Correct 297 ms 102364 KB Output is correct
26 Correct 302 ms 102368 KB Output is correct
27 Correct 278 ms 102596 KB Output is correct
28 Correct 283 ms 102548 KB Output is correct
29 Correct 323 ms 102056 KB Output is correct
30 Correct 281 ms 102740 KB Output is correct
31 Correct 281 ms 102224 KB Output is correct
32 Correct 273 ms 101200 KB Output is correct
33 Correct 1 ms 6492 KB Output is correct
34 Correct 2 ms 6748 KB Output is correct
35 Correct 3 ms 14428 KB Output is correct
36 Correct 2 ms 11612 KB Output is correct
37 Correct 1 ms 10588 KB Output is correct
38 Runtime error 19 ms 11864 KB Execution killed with signal 11
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 12732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 3 ms 14428 KB Output is correct
4 Correct 2 ms 11612 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Runtime error 48 ms 51864 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 16220 KB Output is correct
3 Correct 2 ms 16216 KB Output is correct
4 Correct 2 ms 16220 KB Output is correct
5 Correct 3 ms 16216 KB Output is correct
6 Correct 2 ms 16220 KB Output is correct
7 Correct 2 ms 15452 KB Output is correct
8 Correct 1 ms 14684 KB Output is correct
9 Correct 2 ms 16220 KB Output is correct
10 Correct 3 ms 16220 KB Output is correct
11 Correct 2 ms 17848 KB Output is correct
12 Correct 2 ms 16220 KB Output is correct
13 Correct 1 ms 6584 KB Output is correct
14 Correct 1 ms 12636 KB Output is correct
15 Correct 1 ms 10692 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 16 ms 24152 KB Output is correct
18 Correct 16 ms 24156 KB Output is correct
19 Correct 16 ms 25692 KB Output is correct
20 Correct 18 ms 24280 KB Output is correct
21 Correct 17 ms 23896 KB Output is correct
22 Correct 15 ms 24152 KB Output is correct
23 Correct 16 ms 25692 KB Output is correct
24 Correct 7 ms 19036 KB Output is correct
25 Correct 297 ms 102364 KB Output is correct
26 Correct 302 ms 102368 KB Output is correct
27 Correct 278 ms 102596 KB Output is correct
28 Correct 283 ms 102548 KB Output is correct
29 Correct 323 ms 102056 KB Output is correct
30 Correct 281 ms 102740 KB Output is correct
31 Correct 281 ms 102224 KB Output is correct
32 Correct 273 ms 101200 KB Output is correct
33 Runtime error 19 ms 11864 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -