답안 #914964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914964 2024-01-23T03:06:07 Z adaawf 최솟값 배열 (IZhO11_hyper) C++17
100 / 100
225 ms 61356 KB
#include <iostream>
using namespace std;
int a[36][36][36][36], b[36][36][36][36], f[36][36][36][36], c[36][36][36][36], g[36][36][36][36];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                for (int l = 1; l <= n; l++) {
                    cin >> a[i][j][k][l];
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                for (int l = 1; l <= n - m + 1; l++) {
                    b[i][j][k][l] = 1e9;
                    for (int u = l; u < l + m; u++) {
                        b[i][j][k][l] = min(b[i][j][k][l], a[i][j][k][u]);
                    }
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n - m + 1; k++) {
                for (int l = 1; l <= n - m + 1; l++) {
                    f[i][j][k][l] = 1e9;
                    for (int u = k; u < k + m; u++) {
                        f[i][j][k][l] = min(f[i][j][k][l], b[i][j][u][l]);
                    }
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - m + 1; j++) {
            for (int k = 1; k <= n - m + 1; k++) {
                for (int l = 1; l <= n - m + 1; l++) {
                    c[i][j][k][l] = 1e9;
                    for (int u = j; u < j + m; u++) {
                        c[i][j][k][l] = min(c[i][j][k][l], f[i][u][k][l]);
                    }
                }
            }
        }
    }
    for (int i = 1; i <= n - m + 1; i++) {
        for (int j = 1; j <= n - m + 1; j++) {
            for (int k = 1; k <= n - m + 1; k++) {
                for (int l = 1; l <= n - m + 1; l++) {
                    g[i][j][k][l] = 1e9;
                    for (int u = i; u < i + m; u++) {
                        g[i][j][k][l] = min(g[i][j][k][l], c[u][j][k][l]);
                    }
                    cout << g[i][j][k][l] << " ";
                }
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 10584 KB Output is correct
2 Correct 2 ms 12888 KB Output is correct
3 Correct 4 ms 18776 KB Output is correct
4 Correct 4 ms 19032 KB Output is correct
5 Correct 4 ms 19036 KB Output is correct
6 Correct 11 ms 21492 KB Output is correct
7 Correct 11 ms 21572 KB Output is correct
8 Correct 17 ms 26716 KB Output is correct
9 Correct 30 ms 30300 KB Output is correct
10 Correct 18 ms 26712 KB Output is correct
11 Correct 44 ms 33856 KB Output is correct
12 Correct 87 ms 39248 KB Output is correct
13 Correct 72 ms 36148 KB Output is correct
14 Correct 127 ms 46036 KB Output is correct
15 Correct 170 ms 56176 KB Output is correct
16 Correct 105 ms 40620 KB Output is correct
17 Correct 125 ms 44112 KB Output is correct
18 Correct 225 ms 61356 KB Output is correct
19 Correct 166 ms 48328 KB Output is correct
20 Correct 134 ms 44212 KB Output is correct