#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
int a[36][36][36][36];
int calc(int x,int y,int z,int t){
int pas=0;
pas+=t;
pas+=(z-1)*n;
pas+=(y-1)*n*n;
pas+=(x-1)*n*n*n;
return pas;
}
int get(int k,int i,int j,int h,int d1,int d2,int d3,int d4){
if(d1>m-1 || d2>m-1 || d3>m-1 || d4>m-1)
return INT_MAX;
int pas=min(get(k+1,i,j,h,d1+1,d2,d3,d4),min(get(k,i+1,j,h,d1,d2+1,d3,d4),min(get(k,i,j+1,h,d1,d2,d3+1,d4),get(k,i,j,h+1,d1,d2,d3,d4+1))));
return min(pas,a[k][i][j][h]);
}
main(){
cin>>n>>m;
for(int k=1;k<=n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int h=1;h<=n;h++){
int u;
cin>>u;
a[k][i][j][h]=u;
}
}
}
}
int N=n*n*n*n;
for(int k=1;k<=n-m+1;k++){
for(int i=1;i<=n-m+1;i++){
for(int j=1;j<=n-m+1;j++){
for(int h=1;h<=n-m+1;h++){
cout<<get(k,i,j,h,0,0,0,0)<<' ';
}
}
}
}
return 0;
}
Compilation message
hyper.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
hyper.cpp: In function 'int main()':
hyper.cpp:33:5: warning: unused variable 'N' [-Wunused-variable]
int N=n*n*n*n;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
17 ms |
508 KB |
Output is correct |
3 |
Execution timed out |
2017 ms |
1144 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |