#include<bits/stdc++.h>
using namespace std;
int x[35][35][35][35];
int mnm[35][35][35][35][35];
int n,m;
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
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>>x[i][j][k][l];
}
}
}
}
for(int i=n;i>0;i--)
{
for(int j=n;j>0;j--)
{
for(int k=n;k>0;k--)
{
for(int l=n;l>0;l--)
{
mnm[i][j][k][l][1] = x[i][j][k][l];
for(int p=2;p<=m;p++)
{
/*mnm[i][j][k][l][p] = mnm[i][j][k][l][p-1];
mnm[i][j][k][l][p] = min(mnm[i][j][k][l][p], mnm[i+1][j][k][l][p-1]);
mnm[i][j][k][l][p] = min(mnm[i][j][k][l][p], mnm[i][j+1][k][l][p-1]);
mnm[i][j][k][l][p] = min(mnm[i][j][k][l][p], mnm[i][j][k+1][l][p-1]);
mnm[i][j][k][l][p] = min(mnm[i][j][k][l][p], mnm[i][j][k][l+1][p-1]);*/
for(int mask=0;mask<(1<<4);mask++)
{
mnm[i][j][k][l][p] = min(mnm[i][j][k][l][p], mnm[min(n,i+(((1<<0)&mask)!=0))][min(n,j+(((1<<1)&mask)!=0))][min(n,k+(((1<<2)&mask)!=0))][min(n,l+(((1<<3)&mask)!=0))][p-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<<mnm[i][j][k][l][m]<<" ";
}
}
}
}
return 0;
}
/**
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
16732 KB |
Output is correct |
3 |
Correct |
11 ms |
39544 KB |
Output is correct |
4 |
Correct |
8 ms |
39516 KB |
Output is correct |
5 |
Correct |
7 ms |
39516 KB |
Output is correct |
6 |
Correct |
28 ms |
72936 KB |
Output is correct |
7 |
Correct |
43 ms |
72788 KB |
Output is correct |
8 |
Correct |
206 ms |
112720 KB |
Output is correct |
9 |
Correct |
36 ms |
114516 KB |
Output is correct |
10 |
Correct |
158 ms |
112724 KB |
Output is correct |
11 |
Correct |
296 ms |
157120 KB |
Output is correct |
12 |
Correct |
743 ms |
193464 KB |
Output is correct |
13 |
Correct |
1595 ms |
192484 KB |
Output is correct |
14 |
Correct |
283 ms |
198340 KB |
Output is correct |
15 |
Incorrect |
286 ms |
226872 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |