#include<bits/stdc++.h>
using namespace std;
int TC = 0;
void dbg_out() {cout << endl;}
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {cout << " " << H; dbg_out(T...);}
#define debug(...) {cout << "(" << #__VA_ARGS__ << "):"; dbg_out(__VA_ARGS__);}
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define add push_back
#define size(v) (int) v.size()
#define left node * 2, l, (l + r) / 2
#define right node * 2 + 1, (l + r) / 2 + 1, r
#define check() cout << "Why doesn't this stupid a** code work?" << endl;
#define inf (int) 1e18
void solve(){
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, 0))));
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 >> v[i][j][k][l];
}
}
}
}
auto x = v;
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 + 1; l++){
for(int p = l; p <= l + m - 1; p++){
x[i][j][k][l] = min(x[i][j][k][l], v[i][j][k][p]);
}
}
}
}
}
v = x;
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 + 1; l++){
for(int p = l; p <= l + m - 1; p++){
x[i][j][l][k] = min(x[i][j][l][k], v[i][j][p][k]);
}
}
}
}
}
v = x;
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 + 1; l++){
for(int p = l; p <= l + m - 1; p++){
x[i][l][j][k] = min(x[i][l][j][k], v[i][p][j][k]);
}
}
}
}
}
v = x;
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 + 1; l++){
for(int p = l; p <= l + m - 1; p++){
x[l][i][j][k] = min(x[l][i][j][k], v[p][i][j][k]);
}
}
}
}
}
v = x;
for(int i = 0; i < n - m + 1; i++){
for(int j = 0; j < n - m + 1; j++){
for(int k = 0; k < n - m + 1; k++){
for(int l = 0; l < n - m + 1; l++){
cout << v[i][j][k][l] << ' ';
}
}
}
}
cout << endl;
}
signed main(){
int q = 1;
//cin >> q;
while(++TC <= q){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
440 KB |
Output is correct |
3 |
Correct |
4 ms |
604 KB |
Output is correct |
4 |
Correct |
4 ms |
672 KB |
Output is correct |
5 |
Correct |
4 ms |
604 KB |
Output is correct |
6 |
Correct |
18 ms |
1984 KB |
Output is correct |
7 |
Correct |
16 ms |
1884 KB |
Output is correct |
8 |
Correct |
51 ms |
5012 KB |
Output is correct |
9 |
Correct |
62 ms |
6664 KB |
Output is correct |
10 |
Correct |
52 ms |
5212 KB |
Output is correct |
11 |
Correct |
132 ms |
12060 KB |
Output is correct |
12 |
Correct |
282 ms |
24660 KB |
Output is correct |
13 |
Correct |
260 ms |
23448 KB |
Output is correct |
14 |
Correct |
298 ms |
29296 KB |
Output is correct |
15 |
Correct |
451 ms |
44884 KB |
Output is correct |
16 |
Correct |
391 ms |
33208 KB |
Output is correct |
17 |
Correct |
433 ms |
34692 KB |
Output is correct |
18 |
Correct |
580 ms |
54992 KB |
Output is correct |
19 |
Correct |
545 ms |
44132 KB |
Output is correct |
20 |
Correct |
516 ms |
41868 KB |
Output is correct |