Submission #344383

# Submission time Handle Problem Language Result Execution time Memory
344383 2021-01-05T15:28:12 Z nicolaalexandra Hyper-minimum (IZhO11_hyper) C++14
100 / 100
1263 ms 62404 KB
#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 time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 8 ms 2540 KB Output is correct
4 Correct 8 ms 2028 KB Output is correct
5 Correct 7 ms 1516 KB Output is correct
6 Correct 37 ms 5228 KB Output is correct
7 Correct 37 ms 6380 KB Output is correct
8 Correct 127 ms 14444 KB Output is correct
9 Correct 113 ms 6124 KB Output is correct
10 Correct 117 ms 12012 KB Output is correct
11 Correct 292 ms 20844 KB Output is correct
12 Correct 597 ms 32436 KB Output is correct
13 Correct 623 ms 36972 KB Output is correct
14 Correct 628 ms 31596 KB Output is correct
15 Correct 889 ms 38084 KB Output is correct
16 Correct 906 ms 46956 KB Output is correct
17 Correct 862 ms 41684 KB Output is correct
18 Correct 1076 ms 44444 KB Output is correct
19 Correct 1088 ms 49112 KB Output is correct
20 Correct 1263 ms 62404 KB Output is correct