Submission #344383

#TimeUsernameProblemLanguageResultExecution timeMemory
344383nicolaalexandraHyper-minimum (IZhO11_hyper)C++14
100 / 100
1263 ms62404 KiB
#include <bits/stdc++.h> #define DIM 40 #define INF 2000000000 using namespace std; int rmq[7][DIM][DIM][DIM][DIM]; int n,m,i,j,k,t,p,mask; int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n>>m; for (i=1;i<=n;i++) for (j=1;j<=n;j++) for (k=1;k<=n;k++) for (t=1;t<=n;t++) cin>>rmq[0][i][j][k][t]; for (p=1;(1<<p)<=m;p++){ for (i=1;i<=n;i++) for (j=1;j<=n;j++) for (k=1;k<=n;k++) for (t=1;t<=n;t++){ rmq[p][i][j][k][t] = INF; int val = (1<<(p-1)); for (mask=0;mask<16;mask++){ int ii = i, jj = j, kk = k, tt = t; if (mask&1) ii += val; if (mask&2) jj += val; if (mask&4) kk += val; if (mask&8) tt += val; if (ii <= n && jj <= n && kk <= n && tt <= n) rmq[p][i][j][k][t] = min (rmq[p][i][j][k][t],rmq[p-1][ii][jj][kk][tt]); }}} p--; for (i=1;i<=n-m+1;i++) for (j=1;j<=n-m+1;j++) for (k=1;k<=n-m+1;k++) for (t=1;t<=n-m+1;t++){ int mini = INF, val = (1<<p); for (mask=0;mask<16;mask++){ int ii = i, jj = j, kk = k, tt = t; if (mask&1) ii += m - val; if (mask&2) jj += m - val; if (mask&4) kk += m - val; if (mask&8) tt += m - val; if (ii <= n && jj <= n && kk <= n && tt <= n) mini = min (mini,rmq[p][ii][jj][kk][tt]); } cout<<mini<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...