Submission #152633

# Submission time Handle Problem Language Result Execution time Memory
152633 2019-09-08T17:26:01 Z beso123 Hyper-minimum (IZhO11_hyper) C++14
0 / 100
3 ms 504 KB
#include <bits/stdc++.h>
#define int  long long
using namespace std;
int n,m;
int a[36][36][36][36];
int v[1500000],t[1500000*4];
int calc(int x,int y,int z,int t){
    int pas=0;
    pas+=t;
    pas+=(z-1)*n;
    pas+=(y-1)*n*n;
    pas+=(x-1)*n*n*n;
    return pas;
}
void build(int w,int i,int j){
    if(i==j)
        t[w]=v[i];
    else{
        int mid=(i+j)/2;
        build(w*2,i,mid);
        build(w*2+1,mid+1,j);
        t[w]=min(t[w*2],t[w*2+1]);
    }
}
int get(int w,int i,int j,int l,int r){
    if(l>r)
        return INT_MAX;
    if(i==l && j==r)
        return t[w];
    int mid=(i+j)/2;
    return min(get(w*2,i,mid,l,min(r,mid)),get(w*2+1,mid+1,j,max(l,mid+1),r));
}
main(){
cin>>n>>m;
for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
           for(int h=1;h<=n;h++){
            int u;
            cin>>u;
            a[k][i][j][h]=1;
            int pos=calc(k,i,j,h);
            v[pos]=u;

           }
        }
    }
}
int N=n*n*n*n;
build(1,1,N);
for(int k=1;k<=n-m+1;k++){
    for(int i=1;i<=n-m+1;i++){
        for(int j=1;j<=n-m+1;j++){
           for(int h=1;h<=n-m+1;h++){
                int l=calc(k,i,j,h);
                int r=calc(k+m-1,i+m-1,j+m-1,h+m-1);
               cout<<get(1,1,N,l,r)<<' ';

       }
        }
    }
}
return 0;
}

Compilation message

hyper.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 3 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -