#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const int N = 36 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;
int a[N][N][N][N][N];
int n , m;
void solve(int tc) {
cin >> n >> m;
if(n >= N) {
int p = 0;
while(1) p ++;
}
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][1];
}
}
}
}
for(int h = 2; h <= m; h ++) {
for(int i = 1; i <= n-h+1; i ++) {
for(int j = 1; j <= n-h+1; j ++) {
for(int k = 1; k <= n-h+1; k ++) {
for(int l = 1; l <= n-h+1; l ++) {
a[i][j][k][l][h] = inf;
for(int p1: {0 , 1}) {
for(int p2: {0 , 1}) {
for(int p3: {0 , 1}) {
for(int p4: {0 , 1}) {
a[i][j][k][l][h] = min(a[i][j][k][l][h] , a[i+p1][j+p2][k+p3][l+p4][h-1]);
}
}
}
}
}
}
}
}
}
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 ++) {
cout << a[i][j][k][l][m] << ' ';
}
}
}
}
}
/*
*/
main() {
ios;
int tt = 1 , tc = 0;
// cin >> tt;
while(tt --) {
solve(++tc);
}
return 0;
}
Compilation message
hyper.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
65 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
844 KB |
Output is correct |
3 |
Correct |
4 ms |
5492 KB |
Output is correct |
4 |
Correct |
4 ms |
5452 KB |
Output is correct |
5 |
Correct |
4 ms |
5452 KB |
Output is correct |
6 |
Correct |
23 ms |
17860 KB |
Output is correct |
7 |
Correct |
16 ms |
17776 KB |
Output is correct |
8 |
Correct |
58 ms |
41648 KB |
Output is correct |
9 |
Correct |
46 ms |
43336 KB |
Output is correct |
10 |
Correct |
56 ms |
41704 KB |
Output is correct |
11 |
Correct |
145 ms |
81928 KB |
Output is correct |
12 |
Correct |
340 ms |
141292 KB |
Output is correct |
13 |
Correct |
332 ms |
140104 KB |
Output is correct |
14 |
Correct |
257 ms |
146116 KB |
Output is correct |
15 |
Correct |
310 ms |
197956 KB |
Output is correct |
16 |
Correct |
521 ms |
186324 KB |
Output is correct |
17 |
Correct |
529 ms |
187864 KB |
Output is correct |
18 |
Correct |
462 ms |
250884 KB |
Output is correct |
19 |
Correct |
672 ms |
239840 KB |
Output is correct |
20 |
Correct |
677 ms |
237728 KB |
Output is correct |