답안 #901554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901554 2024-01-09T14:36:30 Z LOLOLO 최솟값 배열 (IZhO11_hyper) C++17
0 / 100
2000 ms 241492 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x)   (int)(x).size()
#define len(x)  (int)(x).length()
#define cntbit(x)  builtin_popcnt(x)
#define f   first
#define s   second
#define pb  push_back

const int N = 36;
int dp[N][N][N][N][N];

void minimize(int &a, int b) {
    if (a > b)
        a = b;
}

ll solve() {
    memset(dp, 0x3f, sizeof(dp));

    int n, m;
    cin >> n >> m;

    n--;
    m--;
    for (int a = 0; a <= n; a++) {
        for (int b = 0; b <= n; b++) {
            for (int c = 0; c <= n; c++) {
                for (int d = 0; d <= n; d++) {
                    cin >> dp[a][b][c][d][0];
                }
            }
        }
    }

    vector < vector <int>> all;
    for (int mask = 0; mask < (1 << 4); mask++) {
        vector <int> v;
        for (int j = 0; j < 4; j++) {
            if (mask & (1 << j)) {
                v.pb(1);
            } else {
                v.pb(0);
            }
        }

        all.pb(v);
    }

    for (int a = n; a >= 0; a--) {
        for (int b = n; b >= 0; b--) {
            for (int c = n; c >= 0; c--) {
                for (int d = n; d >= 0; d--) {
                    for (int k = 1; k + min({a, b, c, d}) <= n && k <= m; k++) {
                        for (auto x : all) {
                            minimize(dp[a][b][c][d][k], dp[a + x[0]][b + x[1]][c + x[2]][d + x[3]][k - 1]);
                        }
                    }
                }
            }
        }
    }

    for (int a = 0; a + m <= n; a++) {
        for (int b = 0; b + m <= n; b++) {
            for (int c = 0; c + m <= n; c++) {
                for (int d = 0; d + m <= n; d++) {
                    cout << dp[a][b][c][d][m] << " ";
                }
            }
        }
    }

    return 0;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
        //cout << solve() << '\n';
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 236880 KB Output is correct
2 Correct 28 ms 236988 KB Output is correct
3 Correct 49 ms 237400 KB Output is correct
4 Correct 39 ms 237144 KB Output is correct
5 Correct 34 ms 237144 KB Output is correct
6 Correct 98 ms 237604 KB Output is correct
7 Correct 154 ms 237396 KB Output is correct
8 Correct 709 ms 238376 KB Output is correct
9 Correct 56 ms 239984 KB Output is correct
10 Correct 559 ms 238476 KB Output is correct
11 Correct 1025 ms 240272 KB Output is correct
12 Execution timed out 2050 ms 241492 KB Time limit exceeded
13 Halted 0 ms 0 KB -