#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int sz = 1e5 + 5;
signed main(){
int n, m;
cin >> n >> m;
int a[n][n][n][n];
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
for(int k = 0; k < n; ++k){
for(int l = 0; l < n; ++l){
cin >> a[i][j][k][l];
}
}
}
}
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
for(int k = 0; k < n; ++k){
for(int l = 0; l <= n - m; ++l){
for(int o = 0; o < m; ++o){
a[i][j][k][l] = min(a[i][j][k][l], a[i][j][k][l + o]);
}
}
}
}
}
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
for(int k = 0; k <= n - m; ++k){
for(int l = 0; l < n; ++l){
for(int o = 0; o < m; ++o){
a[i][j][k][l] = min(a[i][j][k][l], a[i][j][k + o][l]);
}
}
}
}
}
for(int i = 0; i < n; ++i){
for(int j = 0; j <= n - m; ++j){
for(int k = 0; k < n; ++k){
for(int l = 0; l < n; ++l){
for(int o = 0; o < m; ++o){
a[i][j][k][l] = min(a[i][j][k][l], a[i][j + o][k][l]);
}
}
}
}
}
for(int i = 0; i <= n - m; ++i){
for(int j = 0; j < n; ++j){
for(int k = 0; k < n; ++k){
for(int l = 0; l < n; ++l){
for(int o = 0; o < m; ++o){
a[i][j][k][l] = min(a[i][j][k][l], a[i + o][j][k][l]);
}
}
}
}
}
for (int i = 0; i <= n - m; ++i){
for (int j = 0; j <= n - m; ++j){
for (int k = 0; k <= n - m; ++k){
for (int l = 0; l <= n - m; l ++){
cout << a[i][j][k][l] << ' ';
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
600 KB |
Output is correct |
4 |
Correct |
4 ms |
444 KB |
Output is correct |
5 |
Correct |
4 ms |
604 KB |
Output is correct |
6 |
Correct |
17 ms |
1344 KB |
Output is correct |
7 |
Correct |
15 ms |
1116 KB |
Output is correct |
8 |
Correct |
53 ms |
3300 KB |
Output is correct |
9 |
Correct |
52 ms |
4948 KB |
Output is correct |
10 |
Correct |
44 ms |
3320 KB |
Output is correct |
11 |
Correct |
120 ms |
8068 KB |
Output is correct |
12 |
Correct |
246 ms |
16080 KB |
Output is correct |
13 |
Correct |
222 ms |
14936 KB |
Output is correct |
14 |
Correct |
254 ms |
20820 KB |
Output is correct |
15 |
Correct |
389 ms |
33364 KB |
Output is correct |
16 |
Correct |
337 ms |
21588 KB |
Output is correct |
17 |
Correct |
360 ms |
23120 KB |
Output is correct |
18 |
Correct |
504 ms |
40532 KB |
Output is correct |
19 |
Correct |
494 ms |
29428 KB |
Output is correct |
20 |
Correct |
405 ms |
27384 KB |
Output is correct |