답안 #17708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17708 2016-01-12T09:02:08 Z chrome 최솟값 배열 (IZhO11_hyper) C++
100 / 100
526 ms 49776 KB
#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][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][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];
					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 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) {
					for (int r = 0, w = k; r < m && w > 0; ++r, --w) {
						S(z[i][j][w][l], 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)
							S(val, z[j1][j2][i3][i4]);
							/* for (int j4 = i4; j4 <= i4 + m - 1; ++j4)
								S(val, z[j1][j2][i3][j4]);
							/* 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;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 49776 KB Output is correct
2 Correct 0 ms 49776 KB Output is correct
3 Correct 0 ms 49776 KB Output is correct
4 Correct 0 ms 49776 KB Output is correct
5 Correct 0 ms 49776 KB Output is correct
6 Correct 0 ms 49776 KB Output is correct
7 Correct 0 ms 49776 KB Output is correct
8 Correct 37 ms 49776 KB Output is correct
9 Correct 37 ms 49776 KB Output is correct
10 Correct 44 ms 49776 KB Output is correct
11 Correct 116 ms 49776 KB Output is correct
12 Correct 181 ms 49776 KB Output is correct
13 Correct 221 ms 49776 KB Output is correct
14 Correct 193 ms 49776 KB Output is correct
15 Correct 423 ms 49776 KB Output is correct
16 Correct 273 ms 49776 KB Output is correct
17 Correct 416 ms 49776 KB Output is correct
18 Correct 433 ms 49776 KB Output is correct
19 Correct 526 ms 49776 KB Output is correct
20 Correct 407 ms 49776 KB Output is correct