#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
int a[36][36][36][36],b[36][36][36][36];
main(){
int n,i,j,k,l,x,m;
scan2(n,m)
for (i=1;i<=n;++i){
for (j=1;j<=n;++j){
for (k=1;k<=n;++k){
for(l=1;l<=n;++l){
scan1(a[i][j][k][l])
b[i][j][k][l]=INF;
}
}
}
}
for (x=0;x<m;++x){
for (i=1;i<=n-m+1;++i)
for (j=1;j<=n-m+1;++j)
for (k=1;k<=n-m+1;++k)
for (l=1;l<=n-m+1;++l){
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l+x]);
}
}
for (x=0;x<m;++x){
for (i=1;i<=n-m+1;++i)
for (j=1;j<=n-m+1;++j)
for (k=1;k<=n-m+1;++k)
for (l=1;l<=n-m+1;++l){
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l+x]);
}
}
for (x=0;x<m;++x){
for (i=1;i<=n-m+1;++i)
for (j=1;j<=n-m+1;++j)
for (k=1;k<=n-m+1;++k)
for (l=1;l<=n-m+1;++l){
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l+x]);
}
}
for (x=0;x<m;++x){
for (i=1;i<=n-m+1;++i)
for (j=1;j<=n-m+1;++j)
for (k=1;k<=n-m+1;++k)
for (l=1;l<=n-m+1;++l){
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l+x]);
}
}
for (x=0;x<m;++x){
for (i=1;i<=n-m+1;++i)
for (j=1;j<=n-m+1;++j)
for (k=1;k<=n-m+1;++k)
for (l=1;l<=n-m+1;++l){
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i][j+x][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j][k+x][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k][l+x]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l]);
b[i][j][k][l] = min(b[i][j][k][l],a[i+x][j+x][k+x][l+x]);
}
}
for (i=1;i<=n-m+1;++i){
for (j=1;j<=n-m+1;++j){
for (k=1;k<=n-m+1;++k){
for(l=1;l<=n-m+1;++l){
cout <<b[i][j][k][l]<<" ";
}
}
}
}
}
Compilation message
hyper.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | main(){
| ^
hyper.cpp: In function 'int main()':
hyper.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
hyper.cpp:23:5: note: in expansion of macro 'scan2'
23 | scan2(n,m)
| ^~~~~
hyper.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
11 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
hyper.cpp:28:21: note: in expansion of macro 'scan1'
28 | scan1(a[i][j][k][l])
| ^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |