Submission #338086

# Submission time Handle Problem Language Result Execution time Memory
338086 2020-12-22T12:59:46 Z juggernaut Hyper-minimum (IZhO11_hyper) C++14
100 / 100
898 ms 58348 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,k,l,g;
int main(){
    cin>>n>>m;
    int dp[5][n][n][n][n];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            for(k=0;k<n;k++)
                for(l=0;l<n;l++)cin>>dp[4][i][j][k][l];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            for(k=0;k<n;k++)
                for(l=0;l<n;l++){
                    dp[3][i][j][k][l]=2e9;
                    for(g=l;g<min(n,l+m);g++)
                        dp[3][i][j][k][l]=min(dp[3][i][j][k][l],dp[4][i][j][k][g]);
                }
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            for(k=0;k<n;k++)
                for(l=0;l<n;l++){
                    dp[2][i][j][k][l]=2e9;
                    for(g=k;g<min(n,k+m);g++)
                        dp[2][i][j][k][l]=min(dp[2][i][j][k][l],dp[3][i][j][g][l]);
                }
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            for(k=0;k<n;k++)
                for(l=0;l<n;l++){
                    dp[1][i][j][k][l]=2e9;
                    for(g=j;g<min(n,j+m);g++)
                        dp[1][i][j][k][l]=min(dp[1][i][j][k][l],dp[2][i][g][k][l]);
                }
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            for(k=0;k<n;k++)
                for(l=0;l<n;l++){
                    dp[0][i][j][k][l]=2e9;
                    for(g=i;g<min(n,i+m);g++)
                        dp[0][i][j][k][l]=min(dp[0][i][j][k][l],dp[1][g][j][k][l]);
                }
    for(i=0;i<n+1-m;i++)
        for(j=0;j<n+1-m;j++)
            for(k=0;k<n+1-m;k++)
                for(l=0;l<n+1-m;l++)
                    cout<<dp[0][i][j][k][l]<<' ';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 6 ms 620 KB Output is correct
4 Correct 6 ms 620 KB Output is correct
5 Correct 6 ms 620 KB Output is correct
6 Correct 27 ms 2028 KB Output is correct
7 Correct 26 ms 1772 KB Output is correct
8 Correct 82 ms 5100 KB Output is correct
9 Correct 105 ms 6912 KB Output is correct
10 Correct 84 ms 5100 KB Output is correct
11 Correct 204 ms 12652 KB Output is correct
12 Correct 430 ms 25708 KB Output is correct
13 Correct 446 ms 24428 KB Output is correct
14 Correct 468 ms 30316 KB Output is correct
15 Correct 718 ms 47468 KB Output is correct
16 Correct 658 ms 35692 KB Output is correct
17 Correct 645 ms 37228 KB Output is correct
18 Correct 898 ms 58348 KB Output is correct
19 Correct 815 ms 47340 KB Output is correct
20 Correct 850 ms 45052 KB Output is correct