#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n >> m;
vector<vector<vector<vector<int>>>> v(n,vector<vector<vector<int>>>(n,vector<vector<int>>(n,vector<int>(n))));
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k = 0;k<n;k++){
for(int c = 0;c<n;c++){
cin >> v[i][j][k][c];
}
}
}
}
for(int x=1;x<=4;x++){
vector<vector<vector<vector<int>>>> v2(n,vector<vector<vector<int>>>(n,vector<vector<int>>(n,vector<int>(n,1e9 + 5))));
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k = 0;k<n;k++){
for(int c = 0;c<n;c++){
for(int d = 0;d<m;d++){
if(x == 1 && c < n - m + 1){
v2[i][j][k][c] = min(v2[i][j][k][c],v[i][j][k][c+d]);
}
if(x == 2 && k < n - m + 1){
v2[i][j][k][c] = min(v2[i][j][k][c],v[i][j][k+d][c]);
}
if(x == 3 && j < n - m + 1){
v2[i][j][k][c] = min(v2[i][j][k][c],v[i][j+d][k][c]);
}
if(x == 4 && i < n - m + 1){
v2[i][j][k][c] = min(v2[i][j][k][c],v[i+d][j][k][c]);
}
}
}
}
}
}
v = v2;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k = 0;k<n;k++){
for(int c = 0;c<n;c++){
if(v[i][j][k][c] != 1e9+5)
cout << v[i][j][k][c] << " ";
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
5 |
Correct |
4 ms |
588 KB |
Output is correct |
6 |
Correct |
15 ms |
1612 KB |
Output is correct |
7 |
Correct |
16 ms |
1560 KB |
Output is correct |
8 |
Correct |
53 ms |
3864 KB |
Output is correct |
9 |
Correct |
59 ms |
5444 KB |
Output is correct |
10 |
Correct |
62 ms |
3856 KB |
Output is correct |
11 |
Correct |
143 ms |
9336 KB |
Output is correct |
12 |
Correct |
361 ms |
17860 KB |
Output is correct |
13 |
Correct |
304 ms |
16772 KB |
Output is correct |
14 |
Correct |
255 ms |
22584 KB |
Output is correct |
15 |
Correct |
385 ms |
30384 KB |
Output is correct |
16 |
Correct |
551 ms |
24524 KB |
Output is correct |
17 |
Correct |
557 ms |
24560 KB |
Output is correct |
18 |
Correct |
447 ms |
36784 KB |
Output is correct |
19 |
Correct |
717 ms |
31360 KB |
Output is correct |
20 |
Correct |
669 ms |
31364 KB |
Output is correct |