Submission #724373

# Submission time Handle Problem Language Result Execution time Memory
724373 2023-04-15T07:03:55 Z vjudge1 Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 2097152 KB
//#include "fish.h"
#include<bits/stdc++.h>
#define ll long long

#include <vector>

ll mx(ll a,ll b){
    if(a>b) return a;
    return b;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
    ll dp[N+1][N][N];
    ll x[N][N];
    for(int i=0;i<=N;i++){
        for(int j=0;j<N;j++){
            if(i!=N){
                x[i][j]=0;
            }
        }
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                dp[i][j][k]=0;
            }
        }
    }
    for(int i=0;i<M;i++){
        x[X[i]][Y[i]]=W[i];
    }
    for(int i=0;i<N;i++){
        for(int j=1;j<N;j++){
            x[i][j]+=x[i][j-1];
        }
    }
    ll m=8;
    if(m>N-1){
        m=N-1;
    }

    for(int i=1;i<N;i++){
        for(int j=0;j<=m;j++){
            for(int k=0;k<=m;k++){
                if(k>=j){
                    for(int l=0;l<=m;l++){
                        dp[i][j][k]=mx(dp[i-1][k][l]+x[i][k]-x[i][j],dp[i][j][k]);
                    }
                }
                else{
                    for(int l=0;l<=k;l++){
                        dp[i][j][k]=mx(dp[i-1][k][l]+x[i][j]-x[i][k],dp[i][j][k]);
                    }
                    for(int l=k+1;l<=j;l++){
                        dp[i][j][k]=mx(dp[i-1][k][l]+x[i-1][j]-x[i-1][l],dp[i][j][k]);
                    }
                    for(int l=j+1;l<=m;l++){
                        dp[i][j][k]=mx(dp[i-1][k][l],dp[i][j][k]);
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=m;i++){
        for(int j=0;j<=m;j++){
            ans=mx(ans,dp[N-1][i][j]);
        }
    }
    return ans;
}
/*
9 9
0 0 1
1 0 4
2 0 5
3 0 2
4 0 1
5 0 5
6 0 3
7 0 2
8 0 1
*/
# Verdict Execution time Memory Grader output
1 Execution timed out 1132 ms 1847400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 925 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 925 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1132 ms 1847400 KB Time limit exceeded
2 Halted 0 ms 0 KB -