#include<bits/stdc++.h>
using namespace std;
const int MAX_D = 45;
const int INF = 1e9+7;
const int MAX_N = 1500002;
int x[MAX_D][MAX_D][MAX_D][MAX_D];
int y[MAX_D][MAX_D][MAX_D][MAX_D];
int z[MAX_D][MAX_D][MAX_D][MAX_D];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
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++)
{
y[i][j][k][l] = z[i][j][k][l] = INF;
}
}
}
}
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 idx = max(l-m+1,1); idx <= l; idx++)
{
y[i][j][k][idx] = min(y[i][j][k][idx], x[i][j][k][l]);
}
}
}
}
}
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++)
{
for(int idx = max(k-m+1,1); idx <= k; idx++)
{
z[i][j][idx][l] = min(z[i][j][idx][l], y[i][j][k][l]);
}
}
}
}
}
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++)
{
for(int i2=i; i2<=i+m-1; i2++)
{
for(int j2=j; j2<=j+m-1; j2++)
{
z[i][j][k][l] = min(z[i][j][k][l], z[i2][j2][k][l]);
}
}
cout<<z[i][j][k][l]<<" ";
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
688 KB |
Output is correct |
3 |
Correct |
2 ms |
1948 KB |
Output is correct |
4 |
Correct |
2 ms |
2064 KB |
Output is correct |
5 |
Correct |
3 ms |
2000 KB |
Output is correct |
6 |
Correct |
9 ms |
4716 KB |
Output is correct |
7 |
Correct |
9 ms |
4548 KB |
Output is correct |
8 |
Correct |
26 ms |
10624 KB |
Output is correct |
9 |
Correct |
34 ms |
12232 KB |
Output is correct |
10 |
Correct |
24 ms |
10568 KB |
Output is correct |
11 |
Correct |
67 ms |
19772 KB |
Output is correct |
12 |
Correct |
174 ms |
31232 KB |
Output is correct |
13 |
Correct |
125 ms |
30144 KB |
Output is correct |
14 |
Correct |
170 ms |
35860 KB |
Output is correct |
15 |
Correct |
255 ms |
49976 KB |
Output is correct |
16 |
Correct |
201 ms |
38316 KB |
Output is correct |
17 |
Correct |
209 ms |
39824 KB |
Output is correct |
18 |
Correct |
279 ms |
58020 KB |
Output is correct |
19 |
Correct |
332 ms |
46952 KB |
Output is correct |
20 |
Correct |
240 ms |
44808 KB |
Output is correct |