#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
#define ld long double
using namespace std;
const ll N = 37;
const ll M = 1e3 + 10;
const ll big = 2e9;
const ll hsh2 = 1964325029;
const ll wp = 491;
const long long mod = 1e9 + 7;
const long double EPS = 1e-14;
const ll block = 1e7;
const ll shift = 2e3;
mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count());
ll n, m;
int z[N][N][N][N];
int p[N][N][N][N][N];
int main() {
speed;
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 >> z[i][j][k][l];
}
}
}
}
for(int i = n; i >= 1; i--) {
for(int j = n; j >= 1; j--) {
for(int k = n; k >= 1; k--) {
for(int l = n; l >= 1; l--) {
p[i][j][k][l][1] = z[i][j][k][l];
for(int h = 2; h <= m; h++) {
p[i][j][k][l][h] = big;
for(int z = 0; z < 2; z++) {
for(int z1 = 0; z1 < 2; z1++) {
for(int z2 = 0; z2 < 2; z2++) {
for(int z3 = 0; z3 < 2; z3++) {
p[i][j][k][l][h] = min(p[i][j][k][l][h], p[i + z][j + z1][k + z2][l + z3][h - 1]);
}
}
}
}
}
}
}
}
}
for(int i = 1; i <= n - m + 1; i++) {
for(int j = 1; j <= n - m + 1; j++) {
for(int l = 1; l <= n - m + 1; l++) {
for(int k = 1; k <= n - m + 1; k++) {
cout << p[i][j][l][k][m] << ' ';
}
}
}
}
}
/*
AAAACACA
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
1132 KB |
Output is correct |
3 |
Correct |
7 ms |
6380 KB |
Output is correct |
4 |
Correct |
6 ms |
6380 KB |
Output is correct |
5 |
Correct |
6 ms |
6380 KB |
Output is correct |
6 |
Correct |
23 ms |
20076 KB |
Output is correct |
7 |
Correct |
27 ms |
20076 KB |
Output is correct |
8 |
Correct |
113 ms |
46188 KB |
Output is correct |
9 |
Correct |
60 ms |
47852 KB |
Output is correct |
10 |
Correct |
88 ms |
46188 KB |
Output is correct |
11 |
Correct |
179 ms |
89708 KB |
Output is correct |
12 |
Correct |
423 ms |
153836 KB |
Output is correct |
13 |
Correct |
684 ms |
152716 KB |
Output is correct |
14 |
Correct |
297 ms |
158636 KB |
Output is correct |
15 |
Correct |
394 ms |
214124 KB |
Output is correct |
16 |
Correct |
962 ms |
202772 KB |
Output is correct |
17 |
Correct |
660 ms |
204140 KB |
Output is correct |
18 |
Correct |
554 ms |
254444 KB |
Output is correct |
19 |
Correct |
798 ms |
243664 KB |
Output is correct |
20 |
Correct |
1362 ms |
241404 KB |
Output is correct |