#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 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)
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];
for (int p = 0, q = l; p < m && q > 0; ++p, --q) {
#define S(x, val) x = min(x, val)
S(y[i][j][k][q], val);
#undef S
}
}
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; j1 <= i1 + m - 1; ++j1)
for (int j2 = i2; j2 <= i2 + m - 1; ++j2)
for (int j3 = i3; j3 <= i3 + m - 1; ++j3)
val = min(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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
33756 KB |
Output is correct |
2 |
Correct |
0 ms |
33756 KB |
Output is correct |
3 |
Correct |
0 ms |
33756 KB |
Output is correct |
4 |
Correct |
0 ms |
33756 KB |
Output is correct |
5 |
Correct |
0 ms |
33756 KB |
Output is correct |
6 |
Correct |
11 ms |
33756 KB |
Output is correct |
7 |
Correct |
5 ms |
33756 KB |
Output is correct |
8 |
Correct |
35 ms |
33756 KB |
Output is correct |
9 |
Correct |
58 ms |
33756 KB |
Output is correct |
10 |
Correct |
70 ms |
33756 KB |
Output is correct |
11 |
Correct |
330 ms |
33756 KB |
Output is correct |
12 |
Correct |
1103 ms |
33756 KB |
Output is correct |
13 |
Correct |
198 ms |
33756 KB |
Output is correct |
14 |
Correct |
318 ms |
33756 KB |
Output is correct |
15 |
Correct |
368 ms |
33756 KB |
Output is correct |
16 |
Correct |
372 ms |
33756 KB |
Output is correct |
17 |
Correct |
1987 ms |
33756 KB |
Output is correct |
18 |
Correct |
525 ms |
33756 KB |
Output is correct |
19 |
Execution timed out |
2000 ms |
33756 KB |
Program timed out |
20 |
Correct |
342 ms |
33756 KB |
Output is correct |