답안 #88679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88679 2018-12-07T12:10:20 Z khohko 최솟값 배열 (IZhO11_hyper) C++17
100 / 100
1687 ms 225628 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll int
#define pb push_back
#define fr first
#define sc second
#define ARRS int(1e5+11)
#define MAX ((int)(1e9+1))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000007)
#define MD ((long long)1000000007)



ll i,j,l,k,n,m,p,d,mx,x,o,y,ans,res,sum;

ll a[36][36][36][36];
ll mn[37][36][36][36][36];
ll N,pp;
ll go(ll n,ll i,ll j,ll k,ll p){
    if(n==1)
        return mn[n][i][j][k][p]=a[i][j][k][p];
    if(i+n>N)return MAX;
    if(j+n>N)return MAX;
    if(k+n>N)return MAX;
    if(p+n>N)return MAX;

    if(mn[n][i][j][k][p]!=MAX)return mn[n][i][j][k][p];
    mn[n][i][j][k][p]=min({a[i][j][k][p],
             go(n-1,i,j,k,p+1),
             go(n-1,i,j,k+1,p),
             go(n-1,i,j,k+1,p+1),
             go(n-1,i,j+1,k,p),
             go(n-1,i,j+1,k,p+1),
             go(n-1,i,j+1,k+1,p),
             go(n-1,i,j+1,k+1,p+1),
             go(n-1,i+1,j,k,p),
             go(n-1,i+1,j,k,p+1),
             go(n-1,i+1,j,k+1,p),
             go(n-1,i+1,j,k+1,p+1),
             go(n-1,i+1,j+1,k,p),
             go(n-1,i+1,j+1,k,p+1),
             go(n-1,i+1,j+1,k+1,p),
             go(n-1,i+1,j+1,k+1,p+1)
             });
   // cout<<i<<" "<<j<<" "<<k<<" "<<p<<" "<<n<<" "<<mn[n][i][j][k][p]<<endl;
    return mn[n][i][j][k][p];
}

int main(){
    #ifdef KHOKHO
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
    #endif //KHOKHO
    cin>>n>>m;
    N=n;
    for(i=0; i<n; i++){
    for(j=0; j<n; j++){
    for(k=0; k<n; k++){
    for(p=0; p<n; p++){
        //cin>>a[i][j][k][p];
        scanf("%d",&a[i][j][k][p]);
     //   cout<<a[i][j][k][p]<<" ";
    }}}}//cout<<endl;}cout<<endl;}cout<<endl;}
    for(i=0; i<n; i++)
        for(j=0; j<n; j++)
         for(k=0; k<n; k++)
                for(p=0; p<n; p++)
                for(pp=0; pp<=m; pp++)
                    mn[pp][i][j][k][p]=MAX;
      for(i=0; i<n; i++)
        for(j=0; j<n; j++)
         for(k=0; k<n; k++)
                for(p=0; p<n; p++)
                    go(m,i,j,k,p);

   // go(m,0,0,1,0);
    for(i=0; i<n-m+1; i++){
    for(j=0; j<n-m+1; j++){
    for(k=0; k<n-m+1; k++){
    for(p=0; p<n-m+1; p++){
     //   cin>>a[i][j][k][p];
        printf("%d ",mn[m][i][j][k][p]);
    }}}}

    return 0;
}

Compilation message

hyper.cpp: In function 'int main()':
hyper.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i][j][k][p]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 892 KB Output is correct
3 Correct 10 ms 6680 KB Output is correct
4 Correct 8 ms 6680 KB Output is correct
5 Correct 8 ms 6680 KB Output is correct
6 Correct 26 ms 9144 KB Output is correct
7 Correct 34 ms 14968 KB Output is correct
8 Correct 115 ms 42548 KB Output is correct
9 Correct 57 ms 42548 KB Output is correct
10 Correct 99 ms 42548 KB Output is correct
11 Correct 241 ms 42548 KB Output is correct
12 Correct 552 ms 72220 KB Output is correct
13 Correct 779 ms 145796 KB Output is correct
14 Correct 341 ms 145796 KB Output is correct
15 Correct 408 ms 145796 KB Output is correct
16 Correct 1150 ms 170328 KB Output is correct
17 Correct 847 ms 170328 KB Output is correct
18 Correct 563 ms 170328 KB Output is correct
19 Correct 1093 ms 170328 KB Output is correct
20 Correct 1687 ms 225628 KB Output is correct