#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define foreach(it, S) for (__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#ifdef inputf
#define fname ""
#else
#define fname "" // <- Here
#endif
const double eps = 1e-9;
const int MaxN = int(2e5) + 256;
const int MOD = int(1e9) + 7;
template <typename T> inline T gcd(T a, T b) {
return b ? gcd (b, a % b) : a;
}
inline bool Palindrome(const string& s) {
return equal(s.begin(), s.end(), s.rbegin());
}
int x[45][45][45][45];
int y[45][45][45][45];
int z[45][45][45];
int mn = INT_MAX;
#define S(x, val) x = min(x, val)
int main() { // _
#ifdef lcl
freopen(fname".in", "r", stdin);
freopen(fname".out", "w", stdout);
#endif
int n, m; scanf("%d%d", &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)
z[i][j][k] = y[i][j][k][l] = INT_MAX;
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) {
scanf("%d", &x[i][j][k][l]);
int val = x[i][j][k][l];
mn = min(mn, val);
for (int p = 0, q = l; p < m && q > 0; ++p, --q) {
S(y[i][j][k][q], val);
}
/* for (int r = 0, w = k; r < m && w > 0; ++r, --w) {
S(z[i][j][w], y[i][j][k][l]);
} */
}
}
for (int i1 = 1; i1 <= n - m + 1; ++i1)
for (int i2 = 1; i2 <= n - m + 1; ++i2)
for (int i3 = 1; i3 <= n - m + 1; ++i3)
for (int i4 = 1; i4 <= n - m + 1; ++i4) {
int val = INT_MAX;
for (int j1 = i1; val != mn && j1 <= i1 + m - 1; ++j1)
for (int j2 = i2; val != mn && j2 <= i2 + m - 1; ++j2)
for (int j3 = i3; val != mn && j3 <= i3 + m - 1; ++j3)
S(val, y[j1][j2][j3][i4]);
/* for (int j4 = i4; j4 <= i4 + m - 1; ++j4) {
val = min(val, x[j1][j2][j3][j4]);
} */
printf("%d ", val);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
34112 KB |
Output is correct |
2 |
Correct |
0 ms |
34112 KB |
Output is correct |
3 |
Correct |
0 ms |
34112 KB |
Output is correct |
4 |
Correct |
0 ms |
34112 KB |
Output is correct |
5 |
Correct |
0 ms |
34112 KB |
Output is correct |
6 |
Correct |
18 ms |
34112 KB |
Output is correct |
7 |
Correct |
9 ms |
34112 KB |
Output is correct |
8 |
Correct |
12 ms |
34112 KB |
Output is correct |
9 |
Correct |
46 ms |
34112 KB |
Output is correct |
10 |
Correct |
67 ms |
34112 KB |
Output is correct |
11 |
Correct |
372 ms |
34112 KB |
Output is correct |
12 |
Correct |
1250 ms |
34112 KB |
Output is correct |
13 |
Correct |
184 ms |
34112 KB |
Output is correct |
14 |
Correct |
379 ms |
34112 KB |
Output is correct |
15 |
Correct |
372 ms |
34112 KB |
Output is correct |
16 |
Correct |
313 ms |
34112 KB |
Output is correct |
17 |
Execution timed out |
2000 ms |
34112 KB |
Program timed out |
18 |
Correct |
573 ms |
34112 KB |
Output is correct |
19 |
Execution timed out |
2000 ms |
34112 KB |
Program timed out |
20 |
Correct |
396 ms |
34112 KB |
Output is correct |