제출 #1108821

#제출 시각아이디문제언어결과실행 시간메모리
1108821Tsagana최솟값 배열 (IZhO11_hyper)C++14
100 / 100
282 ms32244 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

int antiloop = 0;

int n, m;
int X[37][37][37][37];
int Y[37][37][37][37];

void calc(int t) {
	for (int i = 1; i <= n-m+1 + (t == 4 ? 0 : m-1); i++) {
		for (int j = 1; j <= n-m+1 + (t == 3 ? 0 : m-1); j++) {
			for (int l = 1; l <= n-m+1 + (t == 2 ? 0 : m-1); l++) {
				for (int k = 1; k <= n-m+1 + (t == 1 ? 0 : m-1); k++) {
					for (int p = 0; p < m; p++) {
						if (t == 1) Y[i][j][l][k] = min(Y[i][j][l][k], Y[i][j][l][k+p]);
						if (t == 2) Y[i][j][l][k] = min(Y[i][j][l][k], Y[i][j][l+p][k]);
						if (t == 3) Y[i][j][l][k] = min(Y[i][j][l][k], Y[i][j+p][l][k]);
						if (t == 4) Y[i][j][l][k] = min(Y[i][j][l][k], Y[i+p][j][l][k]);
					}
				}
			}
		}
	}
}
void solve () {
	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int l = 1; l <= n; l++) {
				for (int k = 1; k <= n; k++) {
					cin >> X[i][j][l][k];
					Y[i][j][l][k] = X[i][j][l][k];
				}
			}
		}
	}

	for (int i = 1; i <= 4; i++) calc(i);
	//cout << "HERE!"; return ;
	
	for (int i = 1; i <= n-m+1; i++) {
		for (int j = 1; j <= n-m+1; j++) {
			for (int l = 1; l <= n-m+1; l++) {
				for (int k = 1; k <= n-m+1; k++) {
					cout << Y[i][j][l][k] << ' ';
				}
			}
		}
	}
}
int main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...