#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")
using namespace std;
#define int long long
#define ll long long
#define all (x) begin(x), end (x)
#define xx first
#define yy second
#define rep(i, n) for (int i = 0; i < n; ++ i)
using pii = pair <int, int>;
using tii = tuple <int, int, int>;
int n, m;
constexpr int NMAX = (int) 30;
int dp[NMAX + 1][NMAX + 1][NMAX + 1][NMAX + 1];
signed main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
rep(i, n){
rep(i1, n)
{
rep(i2, n){
rep(i3, n){
cin >> dp[i][i1][i2][i3];
}
}
}
}
rep(i, n)
{
rep (i1, n)
{
rep (i2, n)
{
rep (i3, n - m + 1)
{
rep (X, m)
{
dp[i][i1][i2][i3] = min(dp[i][i1][i2][i3], dp[i][i1][i2][i3 + X]);
}
}
}
}
}
rep(i, n) rep(i1, n) rep(i2, n - m + 1) rep(i3, n) rep(X, m) dp[i][i1][i2][i3] = min(dp[i][i1][i2][i3], dp[i][i1][i2 + X][i3]);
rep(i, n) rep(i1, n - m + 1) rep(i2, n) rep(i3, n) rep(X, m) dp[i][i1][i2][i3] = min(dp[i][i1][i2][i3], dp[i][i1 + X][i2][i3]);
rep(i, n - m + 1) rep(i1, n) rep(i2, n) rep(i3, n) rep(X, m) dp[i][i1][i2][i3] = min(dp[i][i1][i2][i3], dp[i + X][i1][i2][i3]);
rep(i, n - m + 1) rep(i1, n - m + 1) rep(i2, n - m + 1) rep(i3, n - m + 1) cout << dp[i][i1][i2][i3] << ' ';
cout << '\n';
return 0 ^ 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |