답안 #17730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17730 2016-01-12T09:26:51 Z Adilkhan 최솟값 배열 (IZhO11_hyper) C++
30 / 100
2000 ms 31720 KB
#include <bits/stdc++.h>

#define pb push_back
#define endl "\n"
#define mp make_pair 
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())

typedef long long ll;

using namespace std;

const ll N = (ll)(5e5) + 322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;

int n, m, sz, a[40][40][40][40], sm, d[40][40][40][40], pre[40][40][40][40];

int getmn(int I, int J, int K, int Q) {
	int res = INF;
	for (int i = I; i <= I + m - 1; ++i) {
		for (int j = J; j <= J + m - 1; ++j) {
			for (int k = K; k <= K + m - 1; ++k) {
				for (int q = Q; q <= Q + m - 1; ++q) {
					res = min(a[i][j][k][q], res);					
					if (res == pre[i][j][k][q]) break;
				}
			}		
		}
	}
	return res;
}

int main () {
	//freopen(fname".in", "r", stdin);
	//freopen(fname".out", "w", stdout);
	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 q = 1; q <= n; ++q) {
			  	scanf("%d", &a[i][j][k][q]);
			  }
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= n; ++k) {
			  for (int q = 0; q < 40; ++q) {
		  		pre[i][j][k][q] = INF;
			  }
			  for (int q = n; q >= 1; --q) {
			  	pre[i][j][k][q] = min(pre[i][j][k][q - 1], a[i][j][k][q]);
			  }
			}
		}
	}

	sm = n - m + 1;
	for (int i = 1; i <= sm; ++i) {
		for (int j = 1; j <= sm; ++j) {
		  for (int k = 1; k <= sm; ++k) {
		  	for (int q = 1; q <= sm; ++q) {
					d[i][j][k][q] = getmn(i, j, k, q);		  			
		  	}
		  }	
		}					
	}
	for (int i = 1; i <= sm; ++i) {
		for (int j = 1; j <= sm; ++j) {
		  for (int k = 1; k <= sm; ++k) {
		  	for (int q = 1; q <= sm; ++q) {
					printf("%d ", d[i][j][k][q]);
				}
		  }	
		}					
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 31720 KB Output is correct
2 Incorrect 0 ms 31720 KB Output isn't correct
3 Correct 0 ms 31720 KB Output is correct
4 Incorrect 5 ms 31720 KB Output isn't correct
5 Incorrect 6 ms 31720 KB Output isn't correct
6 Incorrect 28 ms 31720 KB Output isn't correct
7 Incorrect 44 ms 31720 KB Output isn't correct
8 Correct 43 ms 31720 KB Output is correct
9 Correct 0 ms 31720 KB Output is correct
10 Incorrect 251 ms 31720 KB Output isn't correct
11 Incorrect 1481 ms 31720 KB Output isn't correct
12 Execution timed out 2000 ms 31716 KB Program timed out
13 Correct 96 ms 31720 KB Output is correct
14 Incorrect 522 ms 31720 KB Output isn't correct
15 Incorrect 422 ms 31720 KB Output isn't correct
16 Incorrect 1452 ms 31720 KB Output isn't correct
17 Execution timed out 2000 ms 31716 KB Program timed out
18 Incorrect 698 ms 31720 KB Output isn't correct
19 Execution timed out 2000 ms 31716 KB Program timed out
20 Correct 464 ms 31720 KB Output is correct