답안 #36278

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36278 2017-12-07T04:25:47 Z Kerim 최솟값 배열 (IZhO11_hyper) C++14
100 / 100
619 ms 31324 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int dp[5][35][35][35][35];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				for(int h=0;h<n;h++)
					scanf("%d",&dp[4][i][j][k][h]);
    for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				for(int h=0;h<n;h++){
					dp[3][i][j][k][h]=INF;
					for(int g=h;g<=min(n-1,h+m-1);g++)
						umin(dp[3][i][j][k][h],dp[4][i][j][k][g]);
				}			
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				for(int h=0;h<n;h++){
					dp[2][i][j][k][h]=INF;
					for(int g=k;g<=min(n-1,k+m-1);g++)
						umin(dp[2][i][j][k][h],dp[3][i][j][g][h]);
				}	
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				for(int h=0;h<n;h++){
					dp[1][i][j][k][h]=INF;
					for(int g=j;g<=min(n-1,j+m-1);g++)
						umin(dp[1][i][j][k][h],dp[2][i][g][k][h]);
				}	
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				for(int h=0;h<n;h++){
					dp[0][i][j][k][h]=INF;
					for(int g=i;g<=min(n-1,i+m-1);g++)
						umin(dp[0][i][j][k][h],dp[1][g][j][k][h]);
				}									
	for(int i=0;i+m-1<n;i++)
		for(int j=0;j+m-1<n;j++)
			for(int k=0;k+m-1<n;k++)
				for(int h=0;h+m-1<n;h++)
					printf("%d ",dp[0][i][j][k][h]);
		puts("");						
	return 0;
}

Compilation message

hyper.cpp: In function 'int main()':
hyper.cpp:24:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
hyper.cpp:29:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d",&dp[4][i][j][k][h]);
                                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 31324 KB Output is correct
2 Correct 0 ms 31324 KB Output is correct
3 Correct 6 ms 31324 KB Output is correct
4 Correct 0 ms 31324 KB Output is correct
5 Correct 3 ms 31324 KB Output is correct
6 Correct 16 ms 31324 KB Output is correct
7 Correct 9 ms 31324 KB Output is correct
8 Correct 73 ms 31324 KB Output is correct
9 Correct 49 ms 31324 KB Output is correct
10 Correct 53 ms 31324 KB Output is correct
11 Correct 156 ms 31324 KB Output is correct
12 Correct 253 ms 31324 KB Output is correct
13 Correct 323 ms 31324 KB Output is correct
14 Correct 329 ms 31324 KB Output is correct
15 Correct 449 ms 31324 KB Output is correct
16 Correct 536 ms 31324 KB Output is correct
17 Correct 503 ms 31324 KB Output is correct
18 Correct 599 ms 31324 KB Output is correct
19 Correct 609 ms 31324 KB Output is correct
20 Correct 619 ms 31324 KB Output is correct