답안 #337513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337513 2020-12-21T03:20:42 Z tengiz05 최솟값 배열 (IZhO11_hyper) C++17
0 / 100
2000 ms 20588 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
const int mod = 1e9+7, N = 38;
int msb(int val){return sizeof(int)*8-__builtin_clzll(val);}
int n, m;
int a[N][N][N][N];
int ans[N][N][N][N];
int get(int i, int j, int k, int l){
	int I, J, K, L;
	int res = mod;
	for(I=i;I<=min(n, i+m-1);I++)
		for(J=j;J<=min(n, j+m-1);J++)
			for(K=k;K<=min(n, k+m-1);K++)
				for(L=l;L<=min(n, l+m-1);L++)
					res = min(res, a[I][J][K][L]);
	
	return res;
}
void solve(int test_case){
	int i, j, k, l;
	cin >> n >> m;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			for(k=1;k<=n;k++)
				for(l=1;l<=n;l++)
					cin >> a[i][j][k][l];
	
	int li = n-m+1;
	for(i=1;i<=li;i++)
		for(j=1;j<=li;j++)
			for(k=1;k<=li;k++)
				for(l=1;l<=li;l++){
					ans[i][j][k][l] = get(i,j,k,l);
				}
	
	for(i=1;i<=li;i++)
		for(j=1;j<=li;j++)
			for(k=1;k<=li;k++)
				for(l=1;l<=li;l++)
					cout << ans[i][j][k][l] << ' ';
	
	cout << '\n';
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}





# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 3 ms 1132 KB Output is correct
4 Correct 4 ms 1388 KB Output is correct
5 Correct 3 ms 1644 KB Output is correct
6 Correct 27 ms 3820 KB Output is correct
7 Correct 25 ms 2924 KB Output is correct
8 Correct 33 ms 5996 KB Output is correct
9 Correct 58 ms 11500 KB Output is correct
10 Correct 182 ms 6460 KB Output is correct
11 Correct 920 ms 14444 KB Output is correct
12 Execution timed out 2082 ms 20588 KB Time limit exceeded
13 Halted 0 ms 0 KB -